我如何使用 react-dropzone-uploader 将图像数据上传到 API 并从 API 取回结果图像?

How can i use react-dropzone-uploader for uploading image data to API and get back resulted image from that API?

我正在使用 React-Dropzone-Uploader 将图像上传到我的 API。

API 取 Request Body:

{ 
    image: “file”
} 

并给出 成功响应数据:

{ 
    success: true, message: “success” // all user, plan info data 
} 

我做不到。

我正在使用 axios 进行 API 调用。

''let image=files API.post('/web/v1.0/upload',{image}).then(response=>{ console.log(response.data) })''

您是否看过 https://react-dropzone-uploader.js.org/docs/examples 中提供的示例?

请提供您遇到的确切问题。

您遇到此问题是因为您的请求未经过身份验证 401 与 axios 无关,请检查 API,如果需要身份验证,请像这样发送您的 auth_token

headers : {
  'Content-Type' : 'application/json',
  'Accept' : 'application/json',
  'Authorization' : 'Bearer <token_here>'
}