Last active
February 22, 2017 06:24
-
-
Save clonn/7e1f4d9c1bc370881521b770935ead3d to your computer and use it in GitHub Desktop.
test for node v7.6.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('superagent'); | |
async function getRequest() { | |
let body = await request('http://www.google.com'); | |
return body; | |
} | |
async function run() { | |
let result = await getRequest(); | |
console.log(result.text); | |
} | |
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app.js | |
const timeout = function (delay) { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
console.log('test run'); | |
resolve() | |
}, delay) | |
}) | |
} | |
async function timer () { | |
console.log('timer started') | |
await Promise.resolve(timeout(1000)); | |
console.log('timer finished') | |
} | |
timer(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
of course,
npm i superagent
first.