I have a simple problem which wish someone can shed some light on. After I call an external api returning JSON object. I cannot pass the response outside the callback function. and It returns undefined.
let params = {
key: "value"
};
function callback (data) {
return data
}
//calling the external api which return json object
search.json(params, callback);
no matter how i try to store the data it returns undefined except inside the call back function.
my problem is how can i pass the data to a global scope or access the response after i calling the function though import module.
thanks