Learn how To Use Axios Create
Posted on: February 20, 2021 by Pandu Rijal Pasa
In this article, you will learn how to use Axios.create() the right way.
Before the usage, let’s go for the definition first. The axios.create()
is a function that lets you create a new instance of an Axios service. This would be very helpful to create a dedicated instance for the current project instead of using Axios separately on each request.
The axios.create()
simply takes the configuration object as an argument. Here is an example of the usage :
const instance = axios.create({
baseURL: 'https://your-domain.com/api/',
timeout: 1000,
headers: {'X-Custom-Header': 'foobar'}
});
Share on social media
//