Skip to content

Instantly share code, notes, and snippets.

@jtrussell
Last active February 14, 2017 14:20
Show Gist options
  • Select an option

  • Save jtrussell/33581c73f4c783ea7257a8fc4e28dfa0 to your computer and use it in GitHub Desktop.

Select an option

Save jtrussell/33581c73f4c783ea7257a8fc4e28dfa0 to your computer and use it in GitHub Desktop.
Async/Await boilerplate for jsbin
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src='https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser-polyfill.min.js'></script>
</head>
<body>
<p>Change JavaScript to ES6 / Babel</p>
</body>
</html>
// noprotect
console.clear()
const p = new Promise((resolve, reject) => {
setTimeout(() => {
resolve(5)
})
})
async function fn() {
const val = await p
console.log(val)
}
const fn2 = async () => {
const val = await p
console.log(val)
}
fn()
fn2()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment