用NuxtJs中的feach上传文件和表单数据

问题描述 投票:1回答:1

如何在NuxtJs中使用feach上传文件和表单数据

我尝试multipart/form-dataapplication/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) 
})
vue.js fetch nuxt
1个回答
0
投票

我找到了一篇可能回答您问题的文章。看一看:https://muffinman.io/uploading-files-using-fetch-multipart-form-data/

© www.soinside.com 2019 - 2024. All rights reserved.