小编tes*_*gdj的帖子

错误:多部分:未找到 axios 请求边界(React Native)

如何在 axios post 请求中设置标头?我不断收到 Multipart:Boundary not found (React Native)

我尝试将边界设置为任意数字,但仍然不起作用。- 'Content-Type': 'multipart/form-data; boundary=--hadhba122--'

import axios from 'axios'


### upload image section ###
const uploadImage = async (uri: string) => {
  let fileType = uri.substring(uri.lastIndexOf('.') + 1)
  const baseUrl = 'localurl'
  const formData = new FormData()
  const imageJSON = {
    uri,
    type: `image/${fileType}`,
    name: `photo.${fileType}`,
  }

  formData.append('image', imageJSON)
  const config = {
    headers: {
      'Content-Type': 'multipart/form-data;',
    },
    data: formData,
  }
  return await axios
    .post(baseUrl, formData, config)
    .then((result) => {
      console.log('i am …
Run Code Online (Sandbox Code Playgroud)

node.js react-native axios

1
推荐指数
1
解决办法
2623
查看次数

标签 统计

axios ×1

node.js ×1

react-native ×1