0

我有一个 Aws Api 网关,它以递归方式调用自身(使用新的包体触发到 API 的帖子)。但是,当它尝试调用自身时,会收到 StatusCodeError: 307 Temporary redirect。

该请求是使用 request-promise 包发出的,罪魁祸首函数如下:

    async function callSelf(json)
{

    console.log("Calling self")

    options = {
        method: 'POST',
        uri: url,
        body:JSON.stringify(json)

    };

   await rp(options).then( function (err,resp){console.log(err);console.log(resp)})
    console.log("Called itself")
}

请帮助这已经让我发疯了好几天。

console.log(err) 抛出的错误是:

4a5420a4-73cc-11e8-8d5f-c7ef7ef87853    StatusCodeError: 307 - "<html>\r\n<head><title>307 Temporary Redirect
</title></head>\r\n<body bgcolor=\"white\">\r\n<center><h1>307 Temporary Redirect</h1></center>\r\n<hr><center>CloudFront</center>\r\n</body>\r\n</html>\r\n"
at new StatusCodeError (/var/task/node_modules/request-promise-core/lib/errors.js:32:15)
at Request.plumbing.callback (/var/task/node_modules/request-promise-core/lib/plumbing.js:104:33)
at Request.RP$callback [as _callback] (/var/task/node_modules/request-promise-core/lib/plumbing.js:46:31)
at Request.self.callback (/var/task/node_modules/request/request.js:185:22)
at emitTwo (events.js:126:13)
at Request.emit (events.js:214:7)
at Request.<anonymous> (/var/task/node_modules/request/request.js:1157:10)
at emitOne (events.js:116:13)
at Request.emit (events.js:211:7)
at IncomingMessage.<anonymous> (/var/task/node_modules/request/request.js:1079:12)
at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickDomainCallback (internal/process/next_tick.js:218:9)

编辑:添加错误日志

4

0 回答 0