Axios Flashcards
An axios instance is
a class returned from the axios.create() method that has access to put(), get(), post(), etc methods.
An axios instance is useful for
changing one thing(instance baseURL) changes all places it is used, good for changes between production/development versions
Create an axios instance
const instance = axios.create({baseURL: ‘https://some-domain.com/api/’});
Two advantage of axios vs fetch()
axios have more backwards compatibility;
axios automatically converts data being sent to json format;
axios can be instantiated;
its easier to set a timeout in axios;
axios can intercept requests or responses;
implementing progress bars for downloads is simpler in axios
How to modify the default baseURL of axios?
axios.defaults.baseURL = ‘url’