Created
May 19, 2023 08:31
-
-
Save mrfunctionC3/7cfa9f23cfcd0a2d6f949c21c5dfcf60 to your computer and use it in GitHub Desktop.
axios best practice
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
import axios from "axios"; | |
impoprt http from "http"; | |
import https from "https"; | |
axios.create({ | |
timeout: 30000, | |
httpAgent: new http.Agent({ | |
keepAlive: true | |
maxFreeSockets: 50, | |
maxTotalSockets: 100 | |
}), | |
httpsAgent: new https.Agent({ | |
keepAlive: true | |
maxFreeSockets: 50, | |
maxTotalSockets: 100 | |
}) | |
// 3xx redirects | |
maxRedirects: 10, | |
// maxinum content length | |
maxContentLength: 50 * 1000 * 1000 | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment