fetch - Missing boundary in multipart/form-data POST

前端 未结 6 1572
不知归路
不知归路 2020-11-27 14:45

thanks for stopping by.

I want to send a new FormData() as the body of a POST request using the fetch api

the operatio

6条回答
  •  我在风中等你
    2020-11-27 15:00

    I removed "Content-Type" and added 'Accept' to http headers and it worked for me. Here are the headers I used,

    'headers': new HttpHeaders({
            // 'Content-Type': undefined,
            'Accept': '*/*',
            'Authorization': 
            "Bearer "+(JSON.parse(sessionStorage.getItem('token')).token),
            'Access-Control-Allow-Origin': this.apiURL,
            'Access-Control-Allow-Methods': 'GET, POST, OPTIONS, PUT, PATCH, DELETE',
            'Access-Control-Allow-Headers': 'origin,X-Requested-With,content-type,accept',
            'Access-Control-Allow-Credentials': 'true' 
    
          })
    

提交回复
热议问题