How to post query parameters with Axios?

前端 未结 2 1308
無奈伤痛
無奈伤痛 2020-12-04 18:47

I am trying to post on an API with some query params. This is working on PostMan / Insomnia when I am trying to by passing mail and firstname as query parameters :



        
2条回答
  •  遥遥无期
    2020-12-04 19:26

    axios signature for post is axios.post(url[, data[, config]]). So you want to send params object within the third argument:

    .post(`/mails/users/sendVerificationMail`, null, { params: {
      mail,
      firstname
    }})
    .then(response => response.status)
    .catch(err => console.warn(err));
    

    This will POST an empty body with the two query params:

    POST http://localhost:8000/api/mails/users/sendVerificationMail?mail=lol%40lol.com&firstname=myFirstName

提交回复
热议问题