Commit 00047412 authored by David Votrubec's avatar David Votrubec

Added example of using async await

parent 8d777288
"use strict";
var fetch = require('node-fetch');
// Based on example from Jake Archibald
// See
// but added require()
(async() => {
try {
// url to randomly generated json
const url = '';
// fetch is a new API, better than XMLHttpRequest
// it returns a promise, so it can be awaited
var response = await fetch(url);
var data = await response.json();
console.log('data arrived', data);
} catch (err) {
console.log("Booo", err);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment