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