我正在尝试从网站获取一些数据,但出现以下错误:
{ FetchError: maximum redirect reached at: <URL>
at ClientRequest.<anonymous> (C:\Users\Michal\Desktop\argentina\node_modules\node-fetch\lib\index.js:1498:15)
at ClientRequest.emit (events.js:198:13)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:556:21)
at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17)
at TLSSocket.socketOnData (_http_client.js:442:20)
at TLSSocket.emit (events.js:198:13)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at TLSSocket.Readable.push (_stream_readable.js:224:10)
at TLSWrap.onStreamRead (internal/stream_base_commons.js:94:17)
message:
'maximum redirect reached at: <URL>',
type: 'max-redirect' }
代码是:
const fetch = require("node-fetch");
const asyncFuncAsYouAsked = async () => {
try {
const response = await fetch(URL);
const myJson = await response.json();
let data = JSON.stringify(myJson);
fs.writeFileSync('data.json', data);
console.log(data);
} catch(e) {
console.log("EROOOOR:");
console.dir(e);
}
}
asyncFuncAsYouAsked();
'最大重定向达到:'错误是什么意思,这个问题的解决方案是什么?