TypeError: axios_1.default.create is not a function code example

Example: _axios2.default.all is not a function

// Seems to be related to a babel transpile issue
// Workaround - create a separate instance of axios
// Cause - 'all' is not a function of the instance of axios. See: https://github.com/axios/axios#instance-methods

const axiosInstance = axios.create(/*{
  baseURL: 'https://some-domain.com/api/',
  timeout: 1000,
  headers: {'X-Custom-Header': 'foobar'}
}*/);

// Create get requests using axios instance
const requestOne = axiosInstance.get("https://jsonplaceholder.typicode.com/todos/1");
const requestTwo = axiosInstance.get("https://jsonplaceholder.typicode.com/todos/2");
const requestThree = axiosInstance.get("https://jsonplaceholder.typicode.com/todos/3");

// Call 'all' on axios directly
axios.all([requestOne, requestTwo, requestThree])
  .then((responses) => {
    // Both requests are now complete
    console.log(responses);
  }).catch(errors => {
    // react on errors.
  });