0
Q:

send xmlhttprequest with axios

const axios = require('axios'); // Make a request for a user with a given IDaxios.get('/user?ID=12345')  .then(function (response) {    // handle success    console.log(response);  })  .catch(function (error) {    // handle error    console.log(error);  })  .finally(function () {    // always executed  }); // Optionally the request above could also be done asaxios.get('/user', {    params: {      ID: 12345    }  })  .then(function (response) {    console.log(response);  })  .catch(function (error) {    console.log(error);  })  .finally(function () {    // always executed  });   // Want to use async/await? Add the `async` keyword to your outer function/method.async function getUser() {  try {    const response = await axios.get('/user?ID=12345');    console.log(response);  } catch (error) {    console.error(error);  }}
0
var instance = axios.create({
  baseURL: 'https://some-domain.com/api/',
  headers: {"X-Requested-With": "XMLHttpRequest"}
});
0
const axios = require('axios');

async function makeGetRequest() {

  let res = await axios.get('http://webcode.me');

  let data = res.data;
  console.log(data);
}

makeGetRequest();
0

New to Communities?

Join the community