55

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.

Arr Raj
  • 615
  • 1
  • 6
  • 8

1 Answers1

77

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

JrmDel
  • 390
  • 1
  • 4
  • 16
ChrisG
  • 2,637
  • 18
  • 20
  • 2
    Thanks Chris. So, axios default is 0. (Updated question) But underneath it 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. – Arr Raj Sep 18 '19 at 16:11
  • 8
    @ArrRaj So there could be multiple things happening here. It sounds like you are making this request inside of a node environment and not on a webpage. In that case, there is still not timeout provided by `axios` (https://github.com/axios/axios/blob/master/lib/adapters/http.js#L248). However, there is most likely a server side timeout which is set to 2min. You are most likely hitting that. https://nodejs.org/api/http.html#http_server_timeout – ChrisG Sep 18 '19 at 16:21