Last active
February 9, 2019 12:50
-
-
Save alexjpaz/ee3254140c7f15c873f077694286807d to your computer and use it in GitHub Desktop.
Revisions
-
alexjpaz revised this gist
Feb 9, 2019 . 1 changed file with 34 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1 +1,34 @@ // async /await const request = async (url) => { let client = require('http'); if(url.startsWith('https')) { client = require('https'); } await new Promise((res, rej) => { client.get(url, (rsp) => { rsp.on('end', () => { if(rsp.statusCode === 200) { res(); } else { rej(); } }); }) .on('error', rej); }); }; const main = async (url) => { try { await request(url); console.log('success'); } catch(e) { console.error(e); process.exit(1); throw e; } }; main("http://gooddgle.com"); -
alexjpaz created this gist
Feb 9, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ //