怎么看non-bodyreturns?

How to see non-body returns?

我正在使用 Postman 测试 Azure Functions。对于此代码

context.res = {status: 200, body: "ok", txt: "hello"};

txt不见了。无论如何要检查它还是必须将它包装在 body 下?

根据Azure Functions JavaScript developer guide,响应不包含您指定的对象:

The context.res (response) object has the following properties:

Property Description
body An object that contains the body of the response.
headers An object that contains the response headers.
isRaw Indicates that formatting is skipped for the response.
status The HTTP status code of the response.
cookies An array of HTTP cookie objects that are set in the response. An >HTTP cookie object has a name, value, and other cookie properties, such as >maxAge or sameSite.

我假设 属性 txt 未序列化为响应,因此我认为您无法从邮递员或其他任何其他客户端访问它。

如果你想 return 一些数据你应该把它添加到 body:

context.res = {
    status: 200, 
    body: {
        "message": "ok", 
        "txt": "hello"
    }
};