【发布时间】:2020-09-03 10:33:22
【问题描述】:
在我的后端 Node.js 代码中,我使用 Axios TypeScript 代码上传文档。但是我在使用表单数据时遇到了一个问题。有人能帮我一下吗?来自Axios documentation:
// `data` is the data to be sent as the request body
// Only applicable for request methods 'PUT', 'POST', and 'PATCH'
// When no `transformRequest` is set, must be of one of the following types:
// - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams
// - Browser only: FormData, File, Blob
// - Node only: Stream, Buffer
当我尝试使用FormData 时,我收到此错误ReferenceError: FormData is not defined。所以不确定如何在 TypeScript 中使用表单数据并传递给 Axios。
我不能使用来自 Node.js 的表单数据吗?
【问题讨论】:
-
什么问题?给minimal reproducible example。
-
@jonrsharpe 当我尝试使用
FormData时,我收到此错误ReferenceError: FormData is not defined。所以我不确定如何在打字稿中使用表单数据并传递给 AXIOS -
Edit 问题。
标签: node.js typescript axios multipartform-data form-data