I really don't know what I'm doing wrong here. I'm unable to reassign the variable poster_path with the poster-path fetched in the JSON-call. Now what surprises me is that I've tried to it async to false. And it didn't work.
I've searched through multiple existing answers such as this one (How do I return the response from an asynchronous call?) but haven't found any solution.
function getPoster(id) {
var poster_path = null;
$.getJSON( "https://api.moviedb.org"+id+"?", {async: false}, function( data ) {
poster_path = data.poster_path;
}
}
PS: API-call has been shortened intentionally for this example. I know that it works and that it returns the correct data.