Is it possible to export the value of an await function from an ES6 class? For example, I have a class with a function named getDetails
which looks like this
class Config {
static async getDetails() {
let response = await fetch('url/where/details/are')
let data = await response.json()
return data;
}
}
export { Config }
When I import this class into another file, and call User.getDetails()
, whats returned is Promise {<pending>}
. Is there a way to make the stack wait for a response from the API first?