如何在NuxtJs中使用feach上传文件和表单数据
我尝试multipart/form-data
和application/json
,但不起作用
fetch(this.$store.state.apiUrl+'/gf_forms', {
method: "POST",
headers: {
'Content-Type': 'application/json',
},
//make sure to serialize your JSON body
body: JSON.stringify(this.form)
})
.then(response => response.json())
.then(res => {
console.log(res)
})
我找到了一篇可能回答您问题的文章。看一看:https://muffinman.io/uploading-files-using-fetch-multipart-form-data/