Skip to content

Commit

Permalink
Minor docs tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jul 13, 2021
1 parent ba52e6c commit 099bbfe
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions documentation/tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,31 +206,31 @@ import https from 'https';
import got from 'got';

class MyAgent extends https.Agent {
createConnection(port, options, callback) {
console.log(`Connecting with MyAgent`);
return https.Agent.prototype.createConnection.call(this, port, options, callback);
}
createConnection(port, options, callback) {
console.log(`Connecting with MyAgent`);
return https.Agent.prototype.createConnection.call(this, port, options, callback);
}
}

const proxy = new MyAgent();

const fn = retryCount => {
const stream = got.stream('https://httpbin.org/status/408', {
agent: {
https: retryCount === 0 ? proxy : undefined
}
});

stream.retryCount = retryCount;

stream.on('retry', (retryCount, error) => {
console.log('Creating new retry:', retryCount);
fn(retryCount);
}).on('error', error => {
console.log('Retry count:', error.request.retryCount);
}).resume().on('end', () => {
console.log('`end` event');
});
const stream = got.stream('https://httpbin.org/status/408', {
agent: {
https: retryCount === 0 ? proxy : undefined
}
});

stream.retryCount = retryCount;

stream.on('retry', (retryCount, error) => {
console.log('Creating new retry:', retryCount);
fn(retryCount);
}).on('error', error => {
console.log('Retry count:', error.request.retryCount);
}).resume().on('end', () => {
console.log('`end` event');
});
};

fn(0);
Expand Down

0 comments on commit 099bbfe

Please sign in to comment.