I have a simple class:
class Build {
dataFetched = {};
constructor(id = '') {
this.id = id;
}
getData(){
return request({
some request
}).then(({ data }) => {
this.dataFetched = {...data};
}).catch(({e}) => {
console.log(e);
});
}
showData(){
return this.dataFetched;
}
}
in a different file i am trying to create an object and call getData as well as showData
let test = new Build(input_data);
test.getData();
test.showData();
this returns an empty object, but if method showData just returns "this" the dataFetched property is filled with data from the request.
Not sure what is going on, and would grealty appreciate some help/clarification