Skip to content

Instantly share code, notes, and snippets.

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