Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Axios default timeout

Tags:

I found in the documentation steps to set the timeout value.

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

But I could not find the default value in the official axios documentation - https://github.com/axios/axios

What is the default timeout?

Also, Underneath AXIOS uses http server/client (https://nodejs.org/api/http.html#http_class_http_clientrequest)

Does it use the http default timeout? I see my program timesout after 2 minutes.

like image 746
Arr Raj Avatar asked Sep 18 '19 15:09

Arr Raj


People also ask

What is default timeout Axios?

In Axios, the default timeout is set to 0. However, Axios allows you to set a custom timeout when required. One way to add a timeout is to pass it to the config object.

What is the default timeout for HTTP request?

The default value is 60 seconds. If the value of this stanza entry is set to 0 (or not set), connection timeouts between data fragments are governed instead by the client-connect-timeout stanza entry. The exception to this rule occurs for responses returned over HTTP (TCP).

What is Axios default baseURL?

axios. defaults. baseURL = 'https://api.example.com'; axios.

How do I set the default header in Axios?

Instead of adding the headers to each request, you can put them as default headers, and they will apply to all the requests. To do so, use the defaults. headers property of the axios object. This snippet will add the x-rapidapi-key header to all the requests.


1 Answers

According to the README, it is 0 which means no timeout

// timeout specifies the number of milliseconds before the request times out.

// If the request takes longer than timeout, the request will be aborted. timeout: 1000,

// default is 0 (no timeout)

https://github.com/axios/axios/blob/master/README.md#request-config

like image 73
ChrisG Avatar answered Sep 22 '22 14:09

ChrisG