function getLinks(param) {
let url = 'http://localhost/site/feed.php?url=' + param;
let request = new XMLHttpRequest();
let text = "";
request.responseType = 'text';
request.onload = function(event) {
let obj = request.responseText;
console.log(obj); // Returns: https://some.php.link.php
console.log(typeof obj); // Returns: string
return obj;
};
request.open('GET', url, true);
request.send();
}
function getDeals() {
let url = getLinks('deals_feed');
console.log(url); // Returns: undefined
}
getDeals();
Why is this happening? First two console logs from getLinks() are how it should, but when I call it from the getDeals function, I get undefined.