[英]JSON as Javascript object in Azure http trigger function
const df = require("durable-functions");
module.exports = async function (context, req) {
const client = df.getClient(context);
context.log(`Function Name = '${req.params.functionName}'.`);
context.log(`Body = '${req.body}'.`);
const instanceId = await client.startNew(req.params.functionName, undefined, req.body);
context.log(`Started orchestration with ID = '${instanceId}'.`);
return client.createCheckStatusResponse(context.bindingData.req, instanceId);
};
I have tried to use POSTMAN or https://reqbin.com/ for testing but I always get object. It is a simple case but I don't understand why it is not JSON object.我尝试使用 POSTMAN 或https://reqbin.com/进行测试,但我总是得到 object。这是一个简单的案例,但我不明白为什么它不是 JSON object。
I read this one TypeScript Azure Function Read Body of POST method as JSON but it didn't help me.我读了这个TypeScript Azure Function Read Body of POST method as JSON但它对我没有帮助。
Everything is fine.一切都好。 It is already deserialized json object.
它已经反序列化了 json 对象。 It looks like the normal string in a log after
之后看起来像日志中的普通字符串
JSON.stringify(req.body)
My fault was that I wrongly got it in the orchestrator function from the context.我的错误是我从上下文中错误地在协调器 function 中获取了它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.