Skip to content

Instantly share code, notes, and snippets.

@Gr8Gatsby
Created February 17, 2023 09:53
Show Gist options
  • Save Gr8Gatsby/49e2b58e3f7f7818d423b50142504653 to your computer and use it in GitHub Desktop.
Save Gr8Gatsby/49e2b58e3f7f7818d423b50142504653 to your computer and use it in GitHub Desktop.
SpaceX Lauches Data Visualizer Handlebars
import Handlebars from "https://esm.sh/handlebars";
console.log(Handlebars)
const template = Handlebars.compile(`
<div>{{data.name}}</div>
{{#each data.crew}}
<li>{{role}}</li>
{{/each}}
`);
const onResponse = async (res) => {
const main = document.querySelector("main");
if (!res) {
main.innerHTML = "<pre>Response is empty</pre>";
return;
}
const json = await res.json();
main.innerHTML = template({ data: json });
};
Rapid.onResponse(onResponse);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment