code

fetching a little json

a small async fetch experiment that puts a field from a json response into the page.

html

<div id="test"></div>

javascript

(async function main() {
  const data = await fetch("//echo.jsontest.com/foo/bar/baz/beep")
    .then((res) => res.json())
    .catch((err) => console.error(err));

  const test = document.getElementById("test");

  test.innerHTML = data.foo;
})();

this demo preserves the compiled output and may depend on external libraries or services that are no longer available.

original jsfiddle post