Created
July 6, 2017 16:23
-
-
Save ccnokes/94576dc38225936a3ca892b989c9d0c6 to your computer and use it in GitHub Desktop.
Good default configuration for axios in node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const axios = require('axios'); | |
const http = require('http'); | |
const https = require('https'); | |
module.exports = axios.create({ | |
//60 sec timeout | |
timeout: 60000, | |
//keepAlive pools and reuses TCP connections, so it's faster | |
httpAgent: new http.Agent({ keepAlive: true }), | |
httpsAgent: new https.Agent({ keepAlive: true }), | |
//follow up to 10 HTTP 3xx redirects | |
maxRedirects: 10, | |
//cap the maximum content length we'll accept to 50MBs, just in case | |
maxContentLength: 50 * 1000 * 1000 | |
}); | |
//optionally add interceptors here... |
Hi, i would like to ask,
is this for NODE.JS server ? or i also can apply this method in react app ?
This is for node.js only.
Hi, i would like to ask,
is this for NODE.JS server ? or i also can apply this method in react app ?
@squalvj: Did you ever find a solution for react app? If you could kindly share your solution, would be greatly appreciated!
Thank you @ccnokes and @supertong - solved some very frustrating issues thanks to your comments!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, i would like to ask,
is this for NODE.JS server ? or i also can apply this method in react app ?