'fetching data from map api
Iam using mapbox and trying to fetch some data from this api : JSON
async function getLocation(updateSource) {
// Make a GET request to the API and return the location of the ISS.
try {
const response = await fetch(
'https://api.wheretheiss.at/v1/satellites/25544',
{ method: 'GET' }
);
const { latitude, longitude } = await response.json();
// Fly the map to the location.
map.flyTo({
center: [longitude, latitude],
speed: 0.5
});
// Return the location of the ISS as GeoJSON.
return {
'type': 'FeatureCollection',
'features': [
{
'type': 'Feature',
'geometry': {
'type': 'Point',
'coordinates': [longitude, latitude]
}
}
]
};
} catch (err) {
// If the updateSource interval is defined, clear the interval to stop updating the source.
if (updateSource) clearInterval(updateSource);
throw new Error(err);
}
}
});
so when I tried to fetch the JSON link I get an error ! Is this because the JSON that I want to use has some issues ?? This is the codebase : https://jsfiddle.net/dhap8430
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
