I am trying to create modular code in JS and having trouble passing a variable with values to another method within the same class. I see result as '' right now. Please help!
class foodApp {
constructor() {
this.getjsondata = ''
}
fetchData() {
return fetch("https://jsonplaceholder.typicode.com/users")
.then(response => response.json())
.then(data => {
const result = JSON.stringify(data);
this.getjsondata = result;
})
}
displayHTML() {
return console.log(this.getjsondata)
}
}
new foodApp().displayHTML();