Created
February 17, 2023 09:53
-
-
Save Gr8Gatsby/49e2b58e3f7f7818d423b50142504653 to your computer and use it in GitHub Desktop.
SpaceX Lauches Data Visualizer Handlebars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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