Last active
February 26, 2020 01:01
-
-
Save sammarxz/6ee2e87b0b60e05b26211908cbb816fc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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