Im trying to learn async/await syntax and just not making any progress. I have a snippet below that so far returns me this to the console. The idea is that if my map doesnt have a particular key in it, that it will make a callout - wait for response - and then continue. Instead, I just get the promise. Any pointers on where Im going wrong would be really appreciated.
// mymap is a global var
async function retrieveDetails(key){
let url = '/myurl);
let res = '';
const response = await fetch(url, {
headers: {
'Content-Type': 'application/json',
'Authorization' : 'Bearer '+accessToken
}
})
.then((response) => {
mymap.put(key, response);
})
}
function getValue(key){
if(!mymap.has(key)){
retrieveDetails(key);
}
return mymap.get(key);
}
let result = getValue('foo'); // should return me a value from mymap.