Browse Source

add error catching example

http2
Vsevolod Strukchinsky 9 years ago
parent
commit
f4cf6c7b44
  1. 13
      readme.md

13
readme.md

@ -36,10 +36,15 @@ got('todomvc.com', (error, body, response) => {
});
// Promise mode
got('todomvc.com').then(response => {
console.log(response.body);
//=> '<!doctype html> ...'
});
got('todomvc.com')
.then(response => {
console.log(response.body);
//=> '<!doctype html> ...'
})
.catch(error => {
console.log(error.response.body);
//=> 'Internal server error ...'
});
// Stream mode
got.stream('todomvc.com').pipe(fs.createWriteStream('index.html'));

Loading…
Cancel
Save