StephenGrider / FullstackReactCode

Companion repo to https://www.udemy.com/node-with-react-fullstack-web-development
1.39k stars 1.17k forks source link

Sendgrid axios.post('/api/surveys', survey) not working even after changing updated Mailer.js from udemy Q&A #57

Open proust01 opened 5 years ago

proust01 commented 5 years ago

Hi, Stephen. thanks for all these support. I've been struggling test sending survey object with axios according to lecture 139 but even after updating new Mailer.js file, according to Martin from Q&A, it still doesn't work. This is error I got in my terminal.

and this is my github link : https://github.com/proust01/emaily/blob/master/services/Mailer.js

[0] (node:14108) UnhandledPromiseRejectionWarning: Error: Expecting object for Mail data [0] at Mail.fromData (C:\Users\David Cho\react-node\node_modules\@sendgrid\helpers\classes\mail.js:55:13) [0] at new Mail (C:\Users\David Cho\react-node\node_modules\@sendgrid\helpers\classes\mail.js:44:12) [0] at Function.create (C:\Users\David Cho\react-node\node_modules\@sendgrid\helpers\classes\mail.js:627:12) [0] at MailService.send (C:\Users\David Cho\react-node\node_modules\@sendgrid\mail\src\classes\mail-service.js:174:25) [0] at Mailer.send (C:\Users\David Cho\react-node\services\Mailer.js:28:29) [0] at app.post (C:\Users\David Cho\react-node\routes\surveyRoutes.js:26:17) [0] at Layer.handle [as handle_request] (C:\Users\David Cho\react-node\node_modules\express\lib\router\layer.js:95:5) [0] at next (C:\Users\David Cho\react-node\node_modules\express\lib\router\route.js:137:13) [0] at module.exports (C:\Users\David Cho\react-node\middlewares\requireCredits.js:5:5) [0] at Layer.handle [as handle_request] (C:\Users\David Cho\react-node\node_modules\express\lib\router\layer.js:95:5) [0] at next (C:\Users\David Cho\react-node\node_modules\express\lib\router\route.js:137:13) [0] at module.exports (C:\Users\David Cho\react-node\middlewares\requireLogin.js:5:5) [0] at Layer.handle [as handle_request] (C:\Users\David Cho\react-node\node_modules\express\lib\router\layer.js:95:5) [0] at next (C:\Users\David Cho\react-node\node_modules\express\lib\router\route.js:137:13) [0] at Route.dispatch (C:\Users\David Cho\react-node\node_modules\express\lib\router\route.js:112:3) [0] at Layer.handle [as handle_request] (C:\Users\David Cho\react-node\node_modules\express\lib\router\layer.js:95:5) [0] (node:14108) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)