我想在 axios 发布请求中的 body 参数中传递 formdata 和数据,我尝试了一些方法,但它不起作用。//代码
const form = new FormData();
form.append("file", this.state.selectedFile);
const data={
token:localStorage.getItem('token'),
}
axios.post('http://localhost:3000/api/upload',form, {
onUploadProgress: ProgressEvent => {
this.setState({
loaded: (ProgressEvent.loaded / ProgressEvent.total*100),
})
},
})
.then(response=>{
console.log(response)
}).then(res => {
toast.success('upload success')
})
.catch(err => {
toast.error('upload fail')
})
一只名叫tom的猫
呼如林
相关分类