Can a single Axios Instance be cached and used to make multiple http calls in parallel in a Node API Server? #5576
-
Can I cache a single Axios Instance and use it to make multiple calls to varied endpoints? The thinking is that having set up the Axios Instance with an Auth Bearer Token, set its Timeout and other config, then to avoid having to do this setup again for every new http call, that we cache the single Axios Instance in a module on the API Server, and make all subsequent http requests using this instance. Then we would be having calls in parallel being made using the same single Axios Instance. Is that ok, and is the Axios Instance designed to be able to work in that way, or might we run into timing or contention errors, and so are we then better off making a new Axios Instance for each new incoming http request to the API Server? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Yes we can cache a single Axios Instance and use it to make multiple calls, without running into contention issues. |
Beta Was this translation helpful? Give feedback.
Yes we can cache a single Axios Instance and use it to make multiple calls, without running into contention issues.