Skip to content

Commit

Permalink
update readme example
Browse files Browse the repository at this point in the history
  • Loading branch information
tunnckoCore committed Jun 5, 2015
1 parent cfe6695 commit f312031
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,34 @@ npm test
```js
var handleCallback = require('handle-callback')
var got = require('then-got')

function hybridGot (url, callback) {
var promise = got(url)

if (callback) {
promise = handleCallback(promise, callback)
}

return promise
}

hybridGot('https://github.com')
.then(function (res) {
console.log(res[0])
//=> html content of the page
})
.catch(console.error)

// or both in same time
hybridGot('https://github.com', function (err, res) {
console.log(err) //=> null
console.log(res[0]) //=> html of page
})
.then(function (res) {
console.log(res[0]) //=> html of page
})
.catch(console.error)
```


Expand Down

0 comments on commit f312031

Please sign in to comment.