Answers for "use axios post to send object"

15

axios send post data

// Send a POST request
axios({
  method: 'post',
  url: '/user/12345',
  data: {
    firstName: 'Fred',
    lastName: 'Flintstone'
  },
  headers: {'Authorization': 'Bearer ...'}
});
Posted by: Guest on April-13-2020
0

how to use post method axios

const handleClick = async () => {
    let fd = new FormData();
    fd.append("name", name);
    fd.append("password", password);
    const rep = await axios
      .post("http://localhost/php/api/students/create.php", fd)
      .catch((err) => {
        console.log(err, "axios error");
      });
    console.log(rep.data);
  };
Posted by: Guest on February-26-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language