So my current scenario is I want to fetch JSON data from an URL, parse it and assign it to a window
variable. So the code is as following:
$.getJSON('https://apiv3.iucnredlist.org/api/v3/species/citation/loxodonta%20africana?token=9bb4facb6d23f48efbf424bb05c0c1ef1cf6f468393bc745d42179ac4aca5fee', function(data) {
var id = data.result[0].taxonid;
});
window.speciesId = id;
console.log(window.speciesId);
Is this or something similar possible in JavaScript / jQuery? I'm not very familiar with JS so therefore would be grateful if a workaround can be suggested.