Skip to content

Instantly share code, notes, and snippets.

@marciorodrigues87
Created July 6, 2017 03:44
Show Gist options
  • Save marciorodrigues87/8cf7621b3919ad3ab3be3453e4eddc8a to your computer and use it in GitHub Desktop.
Save marciorodrigues87/8cf7621b3919ad3ab3be3453e4eddc8a to your computer and use it in GitHub Desktop.
request-config-step-six.js
const async = require('async') // <--
const Agent = require('agentkeepalive')
const httpsAgent = new Agent.HttpsAgent({
keepAlive: true,
maxSockets: 100,
socketActiveTTL: 30 * 60 * 1000
})
const request = require('request-promise').defaults({
resolveWithFullResponse: true,
agent: httpsAgent,
gzip: true
})
async.retry(3, (callback, results) => { // <--
request('https://www.vivarealxxx.com.br/')
.then(response => {
console.log('statusCode:', response && response.statusCode)
}).catch(err => {
callback(err) // <--
})
}, (err, result) => {
console.log('error even after retries', err.message) // <--
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment