Skip to content

Instantly share code, notes, and snippets.

@sammarxz
Last active February 26, 2020 01:01
Show Gist options
  • Select an option

  • Save sammarxz/6ee2e87b0b60e05b26211908cbb816fc to your computer and use it in GitHub Desktop.

Select an option

Save sammarxz/6ee2e87b0b60e05b26211908cbb816fc to your computer and use it in GitHub Desktop.
class SiteInfo {
constructor() {
this.DOM.aboutText = document.querySelector(".js--aboutText");
this.url = "[ AQUI VAI A URL RAW DO SEU ARQUIVO JSON ]";
this.data = [];
this.getData();
}
getData = async() => {
try {
await fetch(this.url).then(res => {
if (!res.ok)
throw new Error(response.statusText);
res.json().then(data => {
this.data = data;
this.setData();
});
})
} catch (err) {
console.log(err)
}
}
setData = () => {
this.DOM.aboutText.innerHTML = this.data.aboutText;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment