Been struggling with a little problem for a while. Here, I have a function which searches for album covers via album-cover and Last.FM API. Here's the function itself:
global.url = ' '
function CoverReturn(artist_name, release_name) {
search_covers(last_fm_api_token).search({
artist: artist_name,
album: release_name,
size: 'extralarge'
}, function(err, res) {
res = res.replace("300x300", "1024x1024")
url = res
});
}
CoverReturn(...)
console.log(url)
The problem is that the function doesn't change the url variable at all (and yeah, I really need to change it). I've tried different ways to change this variable, but it just doesn't. What's the problem?