【发布时间】:2018-12-11 10:38:13
【问题描述】:
通过请求模块调用了 Wordpress API。在本地运行我的服务器,调用正确返回。使用邮递员正确返回网址。
但是,当我将我的应用程序部署到 Google App Engine 时,响应返回未定义的请求调用中的响应。
app.get('/api/test', (req, res) => {
console.log("testing");
// res.send({ express: 'Hello From testing' });
request('https://public-api.wordpress.com/rest/v1/sites/testblog.wordpress.com/posts', { json: true }, (err, response, body) => {
console.log(response.statusCode)
console.log(body);
if (err) { return console.log(err); }
console.log(body);
res.send({ express: body.ID })
});
});
【问题讨论】:
标签: node.js http google-app-engine request wordpress-rest-api