axios post request to send form data

后端 未结 9 2300
走了就别回头了
走了就别回头了 2020-11-22 03:40

axios POST request is hitting the url on the controller but setting null values to my POJO class, when I go through developer tools in chrome, the payload conta

9条回答
  •  攒了一身酷
    2020-11-22 03:56

    import axios from "axios";
    import qs from "qs";   
    
    const url = "https://yourapplicationbaseurl/api/user/authenticate";
        let data = {
          Email: "testuser@gmail.com",
          Password: "Admin@123"
        };
        let options = {
          method: "POST",
          headers: { "content-type": "application/x-www-form-urlencoded" },
          data: qs.stringify(data),
          url
        };
        axios(options)
          .then(res => {
            console.log("yeh we have", res.data);
          })
          .catch(er => {
            console.log("no data sorry ", er);
          });
      };
    

提交回复
热议问题