Skip to content

Instantly share code, notes, and snippets.

@Gr8Gatsby
Created March 16, 2023 16:55
Show Gist options
  • Save Gr8Gatsby/6cc183596525c9b7f854d460b313191c to your computer and use it in GitHub Desktop.
Save Gr8Gatsby/6cc183596525c9b7f854d460b313191c to your computer and use it in GitHub Desktop.
import Handlebars from "https://esm.sh/handlebars";
const template = Handlebars.compile(`
<style>
body{
font-family: arial;
font-size: small;
}
.box {
border-radius:10px;
padding: 10px;
margin-bottom: 10px;
margin-left: 10px;
}
.title {
font-weight: bolder;
}
.main {
font-size: x-large;
}
</style>
<span class="main title"> Mission Patch </span>
<div class="main box">
<img src="{{data.links.patch.small}}"/>
</div>
<div><a href="{{data.links.reddit.launch}}">Reddit</a></div>
`);
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