Axios Delete request with body and headers?

后端 未结 11 2119
梦谈多话
梦谈多话 2020-11-28 08:16

I\'m using Axios while programing in ReactJS and I pretend to send a DELETE request to my server.

To do so I need the headers:

headers: {
  \'Authori         


        
11条回答
  •  攒了一身酷
    2020-11-28 09:10

    I encountered the same problem... I solved it by creating a custom axios instance. and using that to make a authenticated delete request..

    const token = localStorage.getItem('token');
    const request = axios.create({
            headers: {
                Authorization: token
            }
        });
    
    await request.delete(', { data: {  }});
    

提交回复
热议问题