设置我的第一个 SNS 节点端点,确认总是空的
setting up my first SNS node end point, the confirmation always is an empty
我正在使用 node.js 作为我的 SNS 端点(这是我的第一个端点,可能缺少正确的 aws 术语)
节点代码很简单
我正在使用快递并且在我的路线中有
router.post('/bounce',
bodyParser.urlencoded({extended: true}),
bodyParser.json(), function (req, res, next) {
console.log("Recieving a new post ");
console.log(req.body);
res.setHeader('Content-Type', 'application/json');
res.send(JSON.stringify({success: true}));
});
当我通过 SNS 控制台订阅时,我看到传入的 post,但它始终是一个空对象。为了验证端点是否正常工作,我 post 来自 postman 和一个 json 对象,它显示了我所期望的
我有节点 amazon sdk ,但我不明白它在图片中的位置
我想我一定是漏掉了一步??
感谢您的帮助
这是我必须做的才能得到我需要的东西
var express = require('express');
var bodyParser = require('body-parser');
var http = require('http');
var router = express.Router();
var app = express();
app.use(bodyParser.json());
app.use(router);
router.post('/bounce', function(req, res){
var chunks = [];
req.on('data', function (chunk) {
chunks.push(chunk);
});
req.on('end', function () {
var message = JSON.parse(chunks.join(''));
console.log(message);
});
res.end();
});
http.createServer( app).listen(4040, function () {
console.log("server listening on port " + 4040);
});
我正在使用 node.js 作为我的 SNS 端点(这是我的第一个端点,可能缺少正确的 aws 术语)
节点代码很简单
我正在使用快递并且在我的路线中有
router.post('/bounce',
bodyParser.urlencoded({extended: true}),
bodyParser.json(), function (req, res, next) {
console.log("Recieving a new post ");
console.log(req.body);
res.setHeader('Content-Type', 'application/json');
res.send(JSON.stringify({success: true}));
});
当我通过 SNS 控制台订阅时,我看到传入的 post,但它始终是一个空对象。为了验证端点是否正常工作,我 post 来自 postman 和一个 json 对象,它显示了我所期望的
我有节点 amazon sdk ,但我不明白它在图片中的位置
我想我一定是漏掉了一步??
感谢您的帮助
这是我必须做的才能得到我需要的东西
var express = require('express');
var bodyParser = require('body-parser');
var http = require('http');
var router = express.Router();
var app = express();
app.use(bodyParser.json());
app.use(router);
router.post('/bounce', function(req, res){
var chunks = [];
req.on('data', function (chunk) {
chunks.push(chunk);
});
req.on('end', function () {
var message = JSON.parse(chunks.join(''));
console.log(message);
});
res.end();
});
http.createServer( app).listen(4040, function () {
console.log("server listening on port " + 4040);
});