Code Monkey home page Code Monkey logo

Comments (5)

tyhopp avatar tyhopp commented on June 19, 2024

@benjaminhoffman any thoughts on this? Thanks!

from gatsby-plugin-mailchimp.

benjaminhoffman avatar benjaminhoffman commented on June 19, 2024

wow this is super weird @tyhopp ... apologies for the delay, was out of town for the holidays.

is your project os? can i take a look? i haven't seen this error before and not even sure where / how to start solving it.

from gatsby-plugin-mailchimp.

tyhopp avatar tyhopp commented on June 19, 2024

Hi @benjaminhoffman, thanks for your reply - no worries!

Wish it was os and I could share, but unfortunately it's a client project under NDA. I can share some code snippets though, maybe helpful?

// mailchimp.js, in the components dir

import React from 'react'
import addToMailchimp from 'gatsby-plugin-mailchimp'

class MailChimp extends React.Component {
	constructor(props) {
		super(props)
		this.state = {
			email: ``,
		}
	}

	// Update state each time user edits their email address
	_handleEmailChange = e => {
		this.setState({ email: e.target.value })
		console.log(this.state.email)
	}

	_handleSubmit = e => {
		e.preventDefault
		addToMailchimp(email, listFields)
			.then(data => {
				// I recommend setting data to React state
				// but you can do whatever you want
				console.log(data)
			})
			.catch(() => {
				// unnecessary because Mailchimp only ever
				// returns a 200 status code
				// see below for how to handle errors
			})
	}

	render() {
		return (
			<form onSubmit={::this._handleSubmit(email, { listFields })}>
				<input
					type="email"
					name="email"
					placeholder="[email protected]"
					onChange={::this._handleEmailChange}
				/>
			</form>
		)
	}
}

export default MailChimp
// gatsby-config.js

require('dotenv').config()

module.exports = {
	siteMetadata: {
		title: 'XXXXX',
	},
	plugins: [
		`gatsby-plugin-react-helmet`,
		`gatsby-plugin-styled-components`,
		`gatsby-transformer-sharp`,
		`gatsby-plugin-sharp`,
		`gatsby-transformer-remark`,
		{
			resolve: 'gatsby-plugin-mailchimp',
			options: {
				endpoint:
					'https://tech.us10.list-manage.com/subscribe/post?u=XXXXXXX',
			},
		},
		{
			resolve: `gatsby-source-filesystem`,
			options: {
				name: `img`,
				path: `${__dirname}/src/assets/img/`,
			},
		},
		{
			resolve: `gatsby-source-contentful`,
			options: {
				spaceId: process.env.CONTENTFUL_SPACE,
				accessToken: process.env.CONTENTFUL_TOKEN,
				host: process.env.CONTENTFUL_HOST || `cdn.contentful.com`,
			},
		},
	],
}

Please let me know if anything else would be helpful - looking forward to working this out!

Thanks again 🎉

from gatsby-plugin-mailchimp.

tyhopp avatar tyhopp commented on June 19, 2024

Ran out of time to try and debug this, closed.

from gatsby-plugin-mailchimp.

ytwguru avatar ytwguru commented on June 19, 2024

Add this to your gatsby-node.js file

exports.onCreateWebpackConfig = ({ actions }) => {
  actions.setWebpackConfig({
    node : {
      fs : "empty"
    }
  })
};

from gatsby-plugin-mailchimp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.