I'm having trouble figuring out what I'm doing wrong in this scenario. The issue is that I can't seem to reassign the variable poster_path with the fetched poster-path from the JSON call. What's puzzling to me is that I even tried setting it async to false, but that didn't fix the problem.
I've looked through various answers, like this one (How do I return the response from an asynchronous call?), but so far, none of them have provided a solution.
function getPoster(id) {
var poster_path = null;
$.getJSON( "https://api.moviedb.org"+id+"?", {async: false}, function( data ) {
poster_path = data.poster_path;
}
}
PS: The API call has been shortened for illustration purposes. It's known to be functioning correctly and returning accurate data.