Skip to content

Instantly share code, notes, and snippets.

@oieioi
Created September 15, 2017 03:34
Show Gist options
  • Save oieioi/b6cf0ee88fd8cceb5fb67d56b326a7f9 to your computer and use it in GitHub Desktop.
Save oieioi/b6cf0ee88fd8cceb5fb67d56b326a7f9 to your computer and use it in GitHub Desktop.
let asyncFunc = () => new Promise((resolve, reject)=>{
setTimeout(()=>{
resolve()
}, 1000);
});
let fakeFetch = async (url) =>{
let result = await asyncFunc(url)
return `GET ${url} 200 OK`
}
let main = async () =>{
let apples = await fakeFetch('http://example.com/apples');
let banana = await fakeFetch('http://example.com/bananas');
console.log([apples, banana].join('\r\n'));
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment