Node.js 为什么可以';我不能访问httprequest变量值吗?

Node.js 为什么可以';我不能访问httprequest变量值吗?,node.js,azure,httprequest,Node.js,Azure,Httprequest,我正在使用httprequest的主体,如下所示: const httpTrigger: AzureFunction = async function ( context: Context, req: HttpRequest ): Promise<void> { try { for (var key in req.body) { console.log('req.body v name=' + key + ' value=' + req.body[

我正在使用httprequest的主体,如下所示:

const httpTrigger: AzureFunction = async function (
  context: Context,
  req: HttpRequest
): Promise<void> {
  try {

     for (var key in req.body) {
      console.log('req.body v name=' + key + ' value=' + req.body[key]);
     }
     const rbi=req.body?.iID;
     console.log({rbi});
     const rbi2=req.body['iID'];
     console.log({rbi2});
第二和第三:

{ rbi: undefined }
{ rbi2: undefined }

但我认为它们应该是一些文本。我缺少什么?

您的代码编译不正确:

此外,当我删除以下行时:

const rbi=req.body?.iID;
     console.log({rbi});
代码正常工作,您得到的是
一些\u文本
,而不是
未定义的

退房

以下是Function App中的相同代码:


您的代码编译不正确:

此外,当我删除以下行时:

const rbi=req.body?.iID;
     console.log({rbi});
代码正常工作,您得到的是
一些\u文本
,而不是
未定义的

退房

以下是Function App中的相同代码:



执行console.log(JSON.stringify(req.body))时会看到什么;带有uuid_值和some_text的变量。将json作为text
{“aT”:“uuid_值”,“iID”:“some_text”}
记录console.log(rbi2)时会看到什么;当您执行console.log(JSON.stringify(req.body))时会看到什么;带有uuid_值和some_text的变量。将json作为text
{“aT”:“uuid_值”,“iID”:“some_text”}
记录console.log(rbi2)时会看到什么;你好谢谢,但您缺少以下内容:
consthttptrigger:AzureFunction=async函数(context:context,req:HttpRequest
你是说在azure函数中你看到了这个问题吗?是的,没错。请检查我的更新响应。同样的事情在函数应用程序中也可以正常工作。你正在创建一个新变量body。我的是请求中的body。嗨。谢谢,但你缺少这个:
const httpTrigger:AzureFunction=异步函数(context:context,req:HttpRequest
你是说在azure函数中你看到了这个问题吗?是的,没错。请检查我更新的响应。同样的事情在函数应用程序中也可以正常工作。你正在创建一个新变量body。我的是来自请求的body。