小编Har*_*ent的帖子

通过 POST 请求上传文件时 NodeJS 获取失败(object2 不可迭代)

我正在尝试使用 NodeJS 中的本机 fetch 上传文件(在节点 17.5 中添加,请参阅https://nodejs.org/ko/blog/release/v17.5.0/)。

但是,我不断收到以下错误 -

TypeError: fetch failed
at Object.processResponse (node:internal/deps/undici/undici:5536:34)
at node:internal/deps/undici/undici:5858:42
at node:internal/process/task_queues:140:7
at AsyncResource.runInAsyncScope (node:async_hooks:202:9)
at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
cause: TypeError: object2 is not iterable
at action (node:internal/deps/undici/undici:1660:39)
at action.next (<anonymous>)
at Object.pull (node:internal/deps/undici/undici:1708:52)
at ensureIsPromise (node:internal/webstreams/util:172:19)
at readableStreamDefaultControllerCallPullIfNeeded
node:internal/webstreams/readablestream:1884:5)
at node:internal/webstreams/readablestream:1974:7
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

      
Run Code Online (Sandbox Code Playgroud)

我使用以下代码来创建并提交表单响应 -

TypeError: fetch failed
at Object.processResponse (node:internal/deps/undici/undici:5536:34)
at node:internal/deps/undici/undici:5858:42
at node:internal/process/task_queues:140:7
at AsyncResource.runInAsyncScope (node:async_hooks:202:9)
at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
cause: …
Run Code Online (Sandbox Code Playgroud)

javascript rest node.js fetch-api

17
推荐指数
1
解决办法
3656
查看次数

标签 统计

fetch-api ×1

javascript ×1

node.js ×1

rest ×1