【发布时间】:2020-08-18 11:59:08
【问题描述】:
我创建了带有 http 触发器的 Azure 函数应用程序,它应该返回 JSON 文件。
这是我的 nodejs 脚本的一部分。
var promise = Promise.all([getFood("first"), getFood("second"), getFood("third")]);
promise.then(function(data) {
let res = JSON.stringify(data);
context.res = {
body: res
};
context.done();
});
它什么也不返回。
但是当我尝试使用类似这样的脚本时,它可以工作:
var promise = Promise.all([getFood("first"), getFood("second"), getFood("third")]);
promise.then(function(data) {
let res = JSON.stringify(data);
});
context.res = {
body:"This is text"
};
context.done();
它会在正文中返回字符串。
【问题讨论】:
标签: javascript node.js json azure azure-function-app