I know this question has been answered many times but something isn't quite clicking in any of the explanations. I'm used to writing python so I'm pretty sure it's the async nature of promises that are eluding me.
I'm trying to make a simple get request and having a nightmare of a time. For some reason no matter now many return
instances I instantiate, nothing seems to actually evaluate and "unwrap" the promise object I'm being returned from my fetch
call. At this point I'm just trying to add more instances of return
, await
, or async
because I'm clearly clueless as to what's going on under the hood. Thanks for your time.
async function get_data(url){
return await fetch(url);
}
function RetreivedList() {
const get_url = "https://km4mqt2a5d.execute-api.us-west-2.amazonaws.com/getList?URL=82ff68cce6444222be46ae1132d55cd8";
console.log('making fetch...');
const foo = get_data(get_url).then(
function(response) {
return response.json()}).then(function(response){
console.log(response.json())
return response;
});
console.log('heres the links!')
console.log(foo);
return(foo);
};
console.log(RetreivedList());
RetreivedList().then(function(data){
return(data.json())
});
codepen:https://codepen.io/dave-mitchell-the-looper/pen/JjYJjXq?editors=1112