我必须调用API来获取一些数据。有我的代码。
getRestaurant = async (id) => {
return await request({
uri: `https://domain/v3/information/${id}`,
json: true,
})
}
但是下面显示了一个错误。
{ RequestError: Error: Parse Error
at new RequestError (/Users/eztable/Desktop/serverlesskit/node_modules/request-promise-core/lib/errors.js:14:15)
at Request.plumbing.callback (/Users/eztable/Desktop/serverlesskit/node_modules/request-promise-core/lib/plumbing.js:87:29)
at Request.RP$callback [as _callback] (/Users/eztable/Desktop/serverlesskit/node_modules/request-promise-core/lib/plumbing.js:46:31)
at self.callback (/Users/eztable/Desktop/serverlesskit/node_modules/request/request.js:186:22)
at Request.emit (events.js:189:13)
at Request.EventEmitter.emit (domain.js:441:20)
at Request.onRequestError (/Users/eztable/Desktop/serverlesskit/node_modules/request/request.js:878:8)
at ClientRequest.emit (events.js:189:13)
at ClientRequest.EventEmitter.emit (domain.js:441:20)
at TLSSocket.socketOnData (_http_client.js:448:9)
at TLSSocket.emit (events.js:189:13)
at TLSSocket.EventEmitter.emit (domain.js:441:20)
at addChunk (_stream_readable.js:284:12)
at readableAddChunk (_stream_readable.js:265:11)
at TLSSocket.Readable.push (_stream_readable.js:220:10)
at TLSWrap.onStreamRead (internal/stream_base_commons.js:94:17)
name: 'RequestError',
message: 'Error: Parse Error',
cause:
{ Error: Parse Error
at TLSSocket.socketOnData (_http_client.js:442:20)
at TLSSocket.emit (events.js:189:13)
at TLSSocket.EventEmitter.emit (domain.js:441:20)
at addChunk (_stream_readable.js:284:12)
at readableAddChunk (_stream_readable.js:265:11)
at TLSSocket.Readable.push (_stream_readable.js:220:10)
at TLSWrap.onStreamRead (internal/stream_base_commons.js:94:17) bytesParsed: 8192, code: 'HPE_HEADER_OVERFLOW' },
error:
{ Error: Parse Error
at TLSSocket.socketOnData (_http_client.js:442:20)
at TLSSocket.emit (events.js:189:13)
at TLSSocket.EventEmitter.emit (domain.js:441:20)
at addChunk (_stream_readable.js:284:12)
at readableAddChunk (_stream_readable.js:265:11)
at TLSSocket.Readable.push (_stream_readable.js:220:10)
at TLSWrap.onStreamRead (internal/stream_base_commons.js:94:17) bytesParsed: 8192, code: 'HPE_HEADER_OVERFLOW' }
我已经搜索了一些解决方案here和here,并尝试添加标志--max-http-header-size
。实际上,我不知道如何编译我的node.js。第二个问题是我的节点应用程序是通过babel转换的。
我无法执行类似npx babel-node app.js --max-http-header-size=16384
的命令
有什么方法可以让我使用带有--max-http-header-size
标志的babel-node? p>
答案 0 :(得分:0)
面对已发行并以this post为单位的相同内容 这可以在
package.json>脚本>开始
例如
"scripts": {
"start": "node index.js --max-http-header-size=80000"
}