fetch("http://api.com/api/query?id=1").
then(ret=>ret.json()).then(ret=>{
let dataNames = ret.data.name.split(", ");
let names = ["Krusl", "Goody", "Timo"];
let outName = "";
for (i=0; i<names.length; i++){
let name = names[i];
let index = dataNames.indexOf(name);
if(-1!==index){
outName = name;
break;
};
};
$("#Name").text("Nick: "+outName);
$("#Year").text("Years old: "+ret.data.year)
})
fetch(`https://api.site.ru/?token=4w5sf4b678ec86b8b&post=${document.querySelector('#GoLink').dataset.post}`)