Skip to content

Commit 4693721

Browse files
Ace Nassrijmdobry
authored andcommitted
Upgrade to latest Sendgrid version (GoogleCloudPlatform#212)
1 parent 31e0341 commit 4693721

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

appengine/sendgrid/app.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,23 @@ app.get('/', function (req, res) {
4343

4444
// [START hello]
4545
app.post('/hello', function (req, res, next) {
46-
Sendgrid.send({
47-
from: SENDGRID_SENDER, // From address
48-
to: req.body.email, // To address
49-
subject: 'Hello World!', // Subject
50-
text: 'Sendgrid on Google App Engine with Node.js' // Content
51-
}, function (err) {
46+
var sgReq = Sendgrid.emptyRequest({
47+
method: 'POST',
48+
path: '/v3/mail/send',
49+
body: {
50+
personalizations: [{
51+
to: [{ email: req.body.email }],
52+
subject: 'Hello World!'
53+
}],
54+
from: { email: SENDGRID_SENDER },
55+
content: [{
56+
type: 'text/plain',
57+
value: 'Sendgrid on Google App Engine with Node.js.'
58+
}]
59+
}
60+
});
61+
62+
Sendgrid.API(sgReq, function (err) {
5263
if (err) {
5364
return next(err);
5465
}

appengine/sendgrid/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
"body-parser": "^1.14.2",
1717
"express": "^4.13.4",
1818
"jade": "^1.11.0",
19-
"sendgrid": "^2.0.0"
19+
"sendgrid": "^4.0.1"
2020
}
21-
}
21+
}

0 commit comments

Comments
 (0)