How can I add raw data body to an axios request?

前端 未结 8 1175
情歌与酒
情歌与酒 2020-12-30 19:44

I am trying to communicate with an API from my React application using Axios. I managed to get the GET request working, but now I need a POST one.

I need the body to

8条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-30 19:57

    axios({
      method: 'post',     //put
      url: url,
      headers: {'Authorization': 'Bearer'+token}, 
      data: {
         firstName: 'Keshav', // This is the body part
         lastName: 'Gera'
      }
    });
    

提交回复
热议问题