when i write this code:
name: async function() {
let ranNumber = ran();
try {
let response = await fetch('data/names.json');
if (!response.ok) {
throw new Error('Network response was not ok');
}
let data = await response.json();
let d = data[ranNumber];
return d
} catch (error) {
console.error('There was a problem fetching the data:', error);
return null;
}
},
i wanna the user of my lib just write nameOFLib.name()
and get the data without do promise then etc
when i do nameOFLib.name()
on console log it give me that :
Promise {<pending>}
[[Prototype]]: Promise
[[PromiseState]]: "fulfilled"
[[PromiseResult]]: "Mark"
and i just need the PromiseResult