I'm making an autocomplete function for a webpage where users can find information about cities and their airports by typing the first letters of the city/airport name. I use javascript fetch for receiving all the active airports from the API:
let airports;
fetch("http://api.travelpayouts.com/data/ru/airports.json")
.then(data => data.json())
.then(data => airports = JSON.parse(data))
.catch(error => console.log(error.message));
It works locally but in case of jsfiddle.net i receive an error:
NetworkError when attempting to fetch resource.
I googled the problem but could only find the reason of such behavior and no solution so I end up with just hardcoding the response body into the fiddle. Any ways to fix it properly?