我尝试用axios从一个网站下载一些图片,但是每次我尝试的时候都得到这个错误。我尝试设置maxContentLength,但是它没有修复任何东西。
这是我代码的一部分
const resp = await axios({
method: 'GET',
url: `${host}/data/${chapterHash}/${page}`,
maxContentLength: 20000,
responseType: 'arraybuffer'
这是错误
const err = new AxiosError(
^
AxiosError: maxContentLength size of -1 exceeded
at IncomingMessage.handlerStreamAborted (C:\Users\alexou\Documents\node-reader\node_modules\axios\dist\node\axios.cjs:2912:23)
at IncomingMessage.emit (node:events:513:28)
at IncomingMessage._destroy (node:_http_incoming:224:10)
at _destroy (node:internal/streams/destroy:102:25)
at IncomingMessage.destroy (node:internal/streams/destroy:64:5)
at TLSSocket.socketCloseListener (node:_http_client:441:11)
at TLSSocket.emit (node:events:525:35)
at node:net:757:14
at TCP.done (node:_tls_wrap:584:7) {
code: 'ERR_BAD_RESPONSE'
1条答案
按热度按时间iq0todco1#
我最后所做的只是添加了一个try{ }catch。代码不再崩溃,但我仍然得到错误。如果你有更好的处理方法,请告诉我。