request.js 416 B

12345678910111213141516171819202122
  1. var deasync = require('../../index.js')
  2. var https = require('https')
  3. var request = deasync(function (url, done) {
  4. https.get(url, function (res) {
  5. res.on('error', done)
  6. res.setEncoding('utf8')
  7. var result = ''
  8. res.on('data', function (data) {
  9. result += data
  10. })
  11. res.on('end', function () {
  12. done(null, result)
  13. })
  14. }).on('error', done)
  15. })
  16. request('https://nodejs.org/en/')