/axios-1.0.0-migration-guide

crowd-sourced migration guide for axios 1.0.0

Creative Commons Zero v1.0 UniversalCC0-1.0

axios-1.0.0-migration-guide

crowd-sourced migration guide for axios1.0.0

axios links


BREAKING CHANGES

Documenting the potential breaking changes between 0.27.2...1.0.0

  1. not all have solutions, but are here for completeness
  2. this guide mentions 1.0.0, but most likely you will want to go to the latest 1.x version

import from @bundled-es-modules

from @ghiscoding via axios/axios#4996 (comment)

If you were using axios@0.x with ESM/Vite, such as in Vue3, your import syntax may have changed:

- import { axios } from '@bundled-es-modules/axios';
+ import axios from 'axios';

AxiosRequestConfig for http interceptors

from @ghiscoding via axios/axios#4996 (comment)

the only other issue we had was with the AxiosRequestConfig interface that we use in our http interceptors and for that we simply had to switch to the InternalAxiosRequestConfig interface

- import { axios, AxiosRequestConfig, AxiosResponse } from '@bundled-es-modules/axios';
+ import axios, { AxiosError, AxiosResponse, InternalAxiosRequestConfig } from 'axios';

function startInterceptors() {
  axios.interceptors.request.use(onRequestFullfilled, onRequestResponseRejected);
  axios.interceptors.response.use(onResponseFullfilled, onRequestResponseRejected);
}

async function onRequestResponseRejected(reason: AxiosError<string>) {
-  const originalRequest = reason.config;
+  const originalRequest = reason.config as InternalAxiosRequestConfig;
   // ...
}

request.headers shape changes

from @josias-r via axios/axios#4996 (reply in thread)

Look out for the shape of request.headers to have changed.

-    if (request.headers?.common?.Authorization) {
-      request.headers.common.Authorization =
+    if (request.headers?.Authorization) {
+      request.headers.Authorization =
        axiosInstance.defaults.headers.common.Authorization;
    }

Serialization of get params

axios/axios#5630

axios.create is not a function

axios/axios#5613

headers are not availabile in beforeRedirect

axios/axios#5365

axios attempts to resolve IPv6 addresses as hostnames

axios/axios#5333

settle helper not exported, or anything from lib/helpers

internals that may not be exposed anymore

axios/axios#5254 axios/axios#5072

error.config on AxiosError ERR_INVALID_CHAR

axios/axios#5254