简体   繁体   中英

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.

日志示例

邮递员示例

I read this one TypeScript Azure Function Read Body of POST method as JSON but it didn't help me.

Everything is fine. It is already deserialized json object. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM