Answers for "axios js 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
5

how to use axios get

const req = async () => {
  const response = await axios.get('https://dog.ceo/api/breeds/list/all')
  console.log(response)
}
req() // Calling this will make a get request and log the response.
Posted by: Guest on December-07-2020
4

axios get Method

const axios = require('axios');

// Make a request for a user with a given ID
axios.get('/user?ID=12345')
  .then(function (response) {
    // handle success
    console.log(response);
  })
  .catch(function (error) {
    // handle error
    console.log(error);
  })
  .then(function () {
    // always executed
  });
Posted by: Guest on July-09-2021
1

axios post

axios.post('https:sample-endpoint.com/user', {
    Name: 'Fred',
    Age: '23'
  })
  .then(function (response) {
    console.log(response);
  })
Posted by: Guest on August-17-2021
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