Skip to content

Instantly share code, notes, and snippets.

View kuldeepdaftary's full-sized avatar
🎯
Focusing

Kuldeep Daftary kuldeepdaftary

🎯
Focusing
  • London
View GitHub Profile
@kuldeepdaftary
kuldeepdaftary / es7-async-await.js
Created May 21, 2017 20:03 — forked from msmfsd/es7-async-await.js
Javascript fetch JSON with ES7 Async Await
// Async/Await requirements: Latest Chrome/FF browser or Babel: https://babeljs.io/docs/plugins/transform-async-to-generator/
// Fetch requirements: Latest Chrome/FF browser or Github fetch polyfill: https://github.com/github/fetch
// async function
async function fetchAsync () {
// await response of fetch call
let response = await fetch('https://api.github.com');
// only proceed once promise is resolved
let data = await response.json();
// only proceed once second promise is resolved
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font: 10px sans-serif;
margin: 0;
}
path.line {