I’m trying to create a root promise function (calling an API) that can be reused by other functions to do more specific requests with the API. However the result I get at the end is an incomplete API response. It looks as if it’s not “awaiting” the response.
// Original API call
const callAPI= async(a, b) =>{
const url = "https://someapi.com/endpoint/" + a + "/" + b;
const results = await fetch(url);
return results
}
// more specific API call using the above function
const specificAPI = async(x) =>{
const results = await callAPI("abc", x);
return results;
}
// main
async function main(){
const results = await specificAPI("123");
console.log(results);
}
The output of the console.log() in the main() function ends up being a fragment of the result. Like its not waiting for the response to return.