简体   繁体   English

JSON 作为 Javascript object 在 Azure http 触发器 function

[英]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.

相关问题 HTTP触发器上的Azure Function App jsreport不起作用 - Azure Function App jsreport on HTTP trigger not working 如何使用自定义错误响应在azure函数http触发器中触发失败 - How to trigger a failure in an azure function http trigger, WITH a custom error response Azure函数在中途重新启动,然后再也不返回(HTTP触发器) - Azure function restarts midway then never returns (HTTP Trigger) 第一次 webhook 响应后的 Azure Http 触发函数挂断套接字 - Azure Http Trigger function Hangup socket after the first webhook response 使用 multipart/form-data 查询 HTTP POST 请求的 Azure http-trigger 函数 - Azure http-trigger function to query HTTP POST request with multipart/form-data 如何使用带有HTTP触发器POST的Azure函数在Cosmos Azure(NOSQL)中更新数据 - How can i update data in Cosmos Azure (NOSQL) , using Azure function with HTTP trigger POST 超时 Azure Function 如果触发其他 azure ZC1C425268E68385D1AB507ZF4C17 - Timeout Azure Function if trigger other azure function 如何使用 HTTP 触发器解析 Azure Function App 中的多部分表单数据? (节点) - How to parse Multi-part form data in an Azure Function App with HTTP Trigger? (NodeJS) 将函数的json结果保存在javascript对象中 - Save json result of a function in javascript object Azure Functions 本地 HTTP 触发器问题及解决方案 - Azure Functions local HTTP trigger issue and solution
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM