Callbacks are completely gone with Node 7 (using –harmony flag)…

4ChanG
Callbacks are completely gone with Node 7 (using –harmony flag)

NodeJS is good now.

var req = require('request-promise');

async function test(url1,url2) {
if(url1 === '' || url2 === '') {
throw new Error();
}
return [await req(url1), await req(url2)];
}

test('http://www.google.com', 'http://www.bing.com')
.then(res=>{
console.log(res);
})
.catch(err=>{
console.log(err);
});

Leave a Reply