我正在使用PostMan发布请求,但无法收到另一端的电子邮件+没有可能指出任何问题的错误, 每个教程都有相同的代码,我无法运行....
请尽快回复,因为这真的很痛苦......
const express = require('express');
const path = require('path');
const bodyParser = require('body-parser');
const SENDGRID_API_KEY ='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';
const SENDGRID_SENDER = 'fazalkarim1994@gmail.com';
const app = express();
app.use(bodyParser.urlencoded({ extended: false }));
app.post('/fazal', (request, response) => {
var sg = require('sendgrid')(SENDGRID_API_KEY);
var request = sg.emptyRequest({
method: 'POST',
path: '/v3/mail/send',
body: {
personalizations: [
{
to: [
{
email: 'bsef13m026@pucit.edu.pk',
},
],
subject: 'Hello World from the SendGrid Node.js Library!',
},
],
from: {
email: 'fazalkarim1994@gmail.com',
},
content: [
{
type: 'text/plain',
value: 'Hello, Email!',
},
],
},
});
//With promise
sg.API(request).then(response => {
console.log(response.statusCode);
console.log(response.body);
console.log(response.headers);
}).catch(error => {
console.log(error.response.statusCode);
});
//With callback
sg.API(request, function(error, response) {
if (error) {
console.log('Error response received');
}
console.log(response.statusCode);
console.log(response.body);
console.log(response.headers);
});
});
app.listen(3000);