Your nodejs instructions do not work
See original GitHub issueI tried to switch over from mailgun-js to the official mailgun.js and everything broke. Following your official documentation:
const DOMAIN = "placeholderDomainHere"
const formData = require('form-data');
const Mailgun = require('mailgun.js');
const mailgun = new Mailgun(formData);
const mg = mailgun.client({username: 'api', key: process.env.MAILGUN_API_KEY);
mg.messages.create(DOMAIN, data)
.then((result) => { console.log(result) } )
.then((err) => { console.log(err) } )
it returns an error:
TypeError: this.formData is not a constructor
this is my current package version:
"form-data": "^4.0.0"
"mailgun.js": "^3.4.0"
Am I missing something here? If not, might want to consider updating the documentation to something that works? 😃
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
15 Common Error Codes in Node.js and How to Fix Them
15. EPERM · Close all instances of your editor before rerunning the command (maybe some files were locked by the editor). · Clean...
Read more >Troubleshoot your Node.js installation
If you have encountered any of these common problems after installing your New Relic Node.js agent, try these troubleshooting tips.
Read more >Top 10 Most Common Node.js Developer Mistakes
Mistake #1: Blocking the event loop. JavaScript in Node.js (just like in the browser) provides a single threaded environment. This means that no...
Read more >npm does not support Node.js v10.19.0 · Issue #3644
My node version is 10.19.0, and my npm version is 6.14. Here is the error message I am getting: npm does not support...
Read more >Node.js is not working?
It looks like your Node.js installation is not working. To test it, either type nodejs or nodejs --version and see if it provides...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It should work with fresher version of form-data package.(At least for me it works with “form-data”: “^4.0.0” and “mailgun.js”: “^3.4.0”). I may be wrong but It seems like you had some npm problem when you tried to install packages the previous time. You can try a newer version but before the install makes sure that you removed node_modules and package-lock.json file if they exist.
@jtsw1990 I think you’re issue is elsewhere then. It works fine for me based on the code you provided. You are however missing a closing
}
in this statementconst mg = mailgun.client({username: 'api', key: process.env.MAILGUN_API_KEY);
But from the error you gave it doesn’t match up with missing a closing brace.Are you able to set up a minimal public repository to reproduce the issue and provide a stack trace of where the issue is occuring?