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

前端 未结 8 1152
情歌与酒
情歌与酒 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 20:13

    How about using direct axios API?

    axios({
      method: 'post',
      url: baseUrl + 'applications/' + appName + '/dataexport/plantypes' + plan,
      headers: {}, 
      data: {
        foo: 'bar', // This is the body part
      }
    });
    

    Source: axios api

提交回复
热议问题