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

前端 未结 8 1118
情歌与酒
情歌与酒 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:50

    There many methods to send raw data with a post request. I personally like this one.

        const url = "your url"
        const data = {key: value}
        const headers = {
            "Content-Type": "application/json"
        }
        axios.post(url, data, headers)
    

提交回复
热议问题