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

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

    You did this in my project

     axios({
      method: "POST",
      url: "https://URL.com/api/services/fetchQuizList",
      headers: {
        "x-access-key": data,
        "x-access-token": token
      }
       data: {
         quiz_name: quizname,
    
       }
    })
      .then(res => {
        console.log("res", res.data.message);
    
      })
      .catch(err => {
        console.log("error in request", err);
      });
    

    This should help

提交回复
热议问题