Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_GATSBY_PLUGIN_MAILCHIMP_ADDRESS__ is not defined #42

Open
isaacsultan opened this issue Jul 17, 2019 · 15 comments
Open

_GATSBY_PLUGIN_MAILCHIMP_ADDRESS__ is not defined #42

isaacsultan opened this issue Jul 17, 2019 · 15 comments

Comments

@isaacsultan
Copy link

System details

  • node v8.9.3
  • npm 6.5.0
  • gatsby: "^2.13.23"
  • gatsby-plugin-mailchimp: "^5.1.2",

Usage

The endpoint is defined in gatsby-config.js as:

{
      resolve: 'gatsby-plugin-mailchimp',
      options: {
        endpoint: `https://gmail.us3.list-manage.com/subscribe/post?u=X&id=Y`, 
      }
    }

And called:

const IndexPage = props => {
  const [email, setEmail] = useState('')

  const handleSubmit = async (e) => {
    e.preventDefault();
    const result = await addToMailChimp(email)
  }

  const handleChange = e => {
    setEmail(e.target.value)
  }
  return (
  ...
  <form onSubmit={handleSubmit}>
      <input type='text' value={email} onChange={handleChange}/>
      <input type="submit" value="Request access"/>
  </form>
}

Stacktrace



node_modules/gatsby-plugin-mailchimp/index.js:88
_callee$
src/pages/index.js:15
  12 | const IndexPage = (props) => {
  13 |   const [email, setEmail] = useState('')
  14 | 
> 15 |   const handleSubmit = async (e) => {
  16 |     e.preventDefault();
  17 |     const result = await addToMailChimp(email)
  18 |   }
View compiled
▼ 7 stack frames were expanded.
tryCatch
node_modules/regenerator-runtime/runtime.js:45
Generator.invoke [as _invoke]
node_modules/regenerator-runtime/runtime.js:271
Generator.prototype.<computed> [as next]
node_modules/regenerator-runtime/runtime.js:97
asyncGeneratorStep
node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js:3
_next
node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js:25
(anonymous function)
node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js:32
(anonymous function)
node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js:21
▲ 7 stack frames were expanded.
handleSubmit
src/pages/index.js:15
  12 | const IndexPage = (props) => {
  13 |   const [email, setEmail] = useState('')
  14 | 
> 15 |   const handleSubmit = async (e) => {
  16 |     e.preventDefault();
  17 |     const result = await addToMailChimp(email)
  18 |   }
View compiled
▼ 20 stack frames were expanded.
HTMLUnknownElement.callCallback
node_modules/react-dom/cjs/react-dom.development.js:150
invokeGuardedCallbackDev
node_modules/react-dom/cjs/react-dom.development.js:200
invokeGuardedCallback
node_modules/react-dom/cjs/react-dom.development.js:257
invokeGuardedCallbackAndCatchFirstError
node_modules/react-dom/cjs/react-dom.development.js:271
executeDispatch
node_modules/react-dom/cjs/react-dom.development.js:562
executeDispatchesInOrder
node_modules/react-dom/cjs/react-dom.development.js:584
executeDispatchesAndRelease
node_modules/react-dom/cjs/react-dom.development.js:681
executeDispatchesAndReleaseTopLevel
node_modules/react-dom/cjs/react-dom.development.js:689
forEachAccumulated
node_modules/react-dom/cjs/react-dom.development.js:663
runEventsInBatch
node_modules/react-dom/cjs/react-dom.development.js:817
runExtractedEventsInBatch
node_modules/react-dom/cjs/react-dom.development.js:825
handleTopLevel
node_modules/react-dom/cjs/react-dom.development.js:4827
batchedUpdates$1
node_modules/react-dom/cjs/react-dom.development.js:20440
batchedUpdates
node_modules/react-dom/cjs/react-dom.development.js:2152
dispatchEvent
node_modules/react-dom/cjs/react-dom.development.js:4906
(anonymous function)
node_modules/react-dom/cjs/react-dom.development.js:20491
unstable_runWithPriority
node_modules/scheduler/cjs/scheduler.development.js:255
interactiveUpdates$1
node_modules/react-dom/cjs/react-dom.development.js:20490
interactiveUpdates
node_modules/react-dom/cjs/react-dom.development.js:2171
dispatchInteractiveEvent
node_modules/react-dom/cjs/react-dom.development.js:4883

@benjaminhoffman
Copy link
Owner

Taking a closer look at your endpoint... are you sure that's a Mailchimp URL? I'm trying to think what else this could be... did you have this working before and it just failed? Or did you just install this?

I usually recommend removing as much as possible from your environment and slowly adding stuff back in to see if there is a conflict. For example, try using the basic starter from Gatsby with your endpoint, see if you can get that working. If not, that means there is a problem with your endpoint. But if it does work then likely there is a conflict with another plugin.

@domtaylor
Copy link

@isaacsultan and also use the method defined in the docs i.e. addToMailchimp instead of camel case.

@Okelm
Copy link

Okelm commented Aug 27, 2019

The same issue observed in my case, which gets resolved after restarting node (npm start).
I was able to add a couple of emails within the last couple of days and then I've run it today and had the same issue:

Uncaught (in promise) ReferenceError: GATSBY_PLUGIN_MAILCHIMP_ADDRESS is not defined
at addToMailchimp

which points to this piece of code:

    // eslint-disable-next-line no-undef
    var endpoint = __GATSBY_PLUGIN_MAILCHIMP_ADDRESS__;

@Okelm
Copy link

Okelm commented Aug 27, 2019

@isaacsultan and also use the method defined in the docs i.e. addToMailchimp instead of camel case.

it's okay, addToMailchimp has a default export

@benjaminhoffman Mailchimp URL looks correct

@nh273
Copy link

nh273 commented Apr 28, 2020

Having the same issue. I have also tried passing my MC endpoint URL in as a param to addToMailChimp but the same ReferenceError: GATSBY_PLUGIN_MAILCHIMP_ADDRESS is not defined is still happening. Endpoint is ok because I send a POST to the same endpoint using Postman and got a 200 back. Could be an issue with conflicting es-lint settings? (shot in the dark, no exp with es-lint)

@scarsam
Copy link

scarsam commented May 1, 2020

@nh273 Any luck with this? I'm having the same issue all the sudden.

@benjaminhoffman
Copy link
Owner

this is so weird. does anyone here have repro steps i can do? no updates have been made to the plugin so 🤷‍♂️

@scarsam
Copy link

scarsam commented May 1, 2020

this is so weird. does anyone here have repro steps i can do? no updates have been made to the plugin so 🤷‍♂️

I'm going to try what you suggested and start removing plugins to see if there is a plugin conflict happening, I'll circle back here later today.

@scarsam
Copy link

scarsam commented May 1, 2020

I had a silly mistake in my gatsby-config.js causing this error. Two of my plugins were defined in the same object.. 🤦

plugins: [{
  resolve: 'gatsby-plugin-mailchimp',
  options: {
    endpoint: 'xxxxx',
  },
  resolve: `gatsby-source-stripe`,
  options: {
    objects: ['Sku', 'Product'],
    secretKey: xxxx,
    downloadFiles: true,
  },
}]

The Stripe and Mailchimp plugin was defined in the same object causing this issue.

plugins: [{
  resolve: 'gatsby-plugin-mailchimp',
  options: {
    endpoint: 'xxxxx',
  },
},
{
  resolve: `gatsby-source-stripe`,
  options: {
    objects: ['Sku', 'Product'],
    secretKey: xxxx,
    downloadFiles: true,
  },
}]

@domtaylor
Copy link

domtaylor commented May 1, 2020 via email

@GenisDiaz
Copy link

I had the same problem but I only had to restart the gatsby server and it worked again

@benjaminhoffman
Copy link
Owner

Looks like this may be solved? Would love to close it but if anyone is still experiencing issues, I am happy to keep it open.

@MuhammadSalah99
Copy link

I have the same issue, when I try to import Mailchimp, I have this error,
"Could not find a declaration file for module 'gatsby-plugin-mailchimp'. 'implicitly has an 'any' type.
Try npm install @types/gatsby-plugin-mailchimp if it exists or add a new declaration (.d.ts) file containing declare module 'gatsby-plugin-mailchimp';ts(7016)"

my gatsby verson is 2.24.2, how can I get pass this error.

@muntiMedia
Copy link

I'm facing the same issue ,it keep saying https is not defined. Even after restart and installing npm install gatsby-plugin-mailchimp, i'm receiving the same message.

@tobinharris
Copy link

I had this issue and it was down to the formatting of my gatsby-config.js.

Weirdly, the previous plugin in the file didn't have a comma after a }. It was the last { in the list but putting the comma in made the the Mailchimp plugin suddenly start seeing the configured endpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants