Last active
September 12, 2017 13:15
-
-
Save pe3/a96ae6c35d5dc7176d4476ccf2d5ba75 to your computer and use it in GitHub Desktop.
quite clean and minimal async http call
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
const r2 = require('r2') | |
// asynchronous arrow functions seem to need an explicit return to work properly | |
const loadUser = async id => { return await r2(`https://jsonplaceholder.typicode.com/users/${id}`).json } | |
(async function() { | |
console.log(await loadUser(2)) | |
})() |
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
{ | |
"name": "playing-with-r2", | |
"version": "1.0.0", | |
"main": "index.js", | |
"dependencies": { | |
"r2": "git+https://git@github.com/mikeal/r2.git" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment