相关疑难解决方法(0)

使用多部分表单数据获取帖子

我正在获取这样的URL:

fetch(url, {
  mode: 'no-cors',
  method: method || null,
  headers: {
    'Accept': 'application/json, application/xml, text/plain, text/html, *.*',
    'Content-Type': 'multipart/form-data'
  },
  body: JSON.stringify(data) || null,
}).then(function(response) {
  console.log(response.status)
  console.log("response");
  console.log(response)
})
Run Code Online (Sandbox Code Playgroud)

我的API期望数据是multipart/form-data这样的,我正在使用content-type这种类型......但是它给了我一个状态代码为400的响应.

我的代码出了什么问题?

javascript fetch fetch-api

65
推荐指数
2
解决办法
10万
查看次数

标签 统计

fetch ×1

fetch-api ×1

javascript ×1