Skip to content

Instantly share code, notes, and snippets.

@davecra
Created July 12, 2024 04:42
Show Gist options
  • Save davecra/a33636bc52b52b2333b73ad178d24c19 to your computer and use it in GitHub Desktop.
Save davecra/a33636bc52b52b2333b73ad178d24c19 to your computer and use it in GitHub Desktop.
Safari Issue
window.setTimeout(async() => {
const o = new thing();
await o.render();
}, 1);
class thing {
render = async () => {
const html = /*html*/`<button id="btn1">Test</button>`;
document.body.innerHTML = html;
const msg = "something here";
document.getElementById("btn1").addEventListener("click", async () => {
await this.#getData(msg);
});
}
#getData = async (msg) => {
const result = await fetch('https://jsonplaceholder.typicode.com/posts/1');
console.log(msg);
const data = await result.json();
console.log(data);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment