我正在尝试使用
form-data
和
axios
,但我得到一个错误:
getHeaders()
不是函数。下面是我的
submit
代码,注意我正在使用
React
具有
Typescript
.
import * as FormData from 'form-data'
import axios from 'axios'
submit(event: React.FormEvent<HTMLFormElement>) {
event.preventDefault()
const { title, description, pictureFile } = this.state
let data = new FormData()
data.append('title', title)
data.append('description', description)
data.append('picture', pictureFile)
axios.post('/api/route', data, {
headers: data.getHeaders() // ERROR: getHeaders is not a function
})
.then(res => handle(res))
.catch(err => handle(err))
}
我感兴趣的是
Authorization
,我可以手动设置,但是需要边界,所以…我最好试试看
Gethe the Server()
发挥作用。
我不觉得有问题,
getHeaders
似乎是
表格数据
应用程序编程接口。
请帮忙。