remove ajax for json requests
This commit is contained in:
parent
90ff0228c5
commit
5a766a809d
|
@ -180,7 +180,11 @@ const index = (() => {
|
||||||
doRedirectToGeometry(overrides[suggestion.value]);
|
doRedirectToGeometry(overrides[suggestion.value]);
|
||||||
} else {
|
} else {
|
||||||
request = $.ajax({
|
request = $.ajax({
|
||||||
|
<<<<<<< Updated upstream
|
||||||
url: 'https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/find',
|
url: 'https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/find',
|
||||||
|
=======
|
||||||
|
url: location.protocol + 'https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/find',
|
||||||
|
>>>>>>> Stashed changes
|
||||||
data: {
|
data: {
|
||||||
text: suggestion.value,
|
text: suggestion.value,
|
||||||
magicKey: suggestion.data,
|
magicKey: suggestion.data,
|
||||||
|
|
|
@ -57,12 +57,7 @@ const navigation = (() => {
|
||||||
const point = await utils.weather.getPoint(latLon.lat, latLon.lon);
|
const point = await utils.weather.getPoint(latLon.lat, latLon.lon);
|
||||||
|
|
||||||
// get stations
|
// get stations
|
||||||
const stationsResponse = await fetch(point.properties.observationStations, {
|
const stations = utils.fetch.json(point.properties.observationStations);
|
||||||
method: 'GET',
|
|
||||||
mode: 'cors',
|
|
||||||
type: 'GET',
|
|
||||||
});
|
|
||||||
const stations = await stationsResponse.json();
|
|
||||||
|
|
||||||
const StationId = stations.features[0].properties.stationIdentifier;
|
const StationId = stations.features[0].properties.stationIdentifier;
|
||||||
|
|
||||||
|
|
|
@ -182,6 +182,18 @@ const utils = (() => {
|
||||||
return url;
|
return url;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ********************************* fetch ********************************************
|
||||||
|
const json = async (url) => {
|
||||||
|
const response = await fetch(url, {
|
||||||
|
method: 'GET',
|
||||||
|
mode: 'cors',
|
||||||
|
type: 'GET',
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) throw new Error(`Fetch error ${response.status} ${response.statusText} while fetching ${url}`);
|
||||||
|
return await response.json();
|
||||||
|
};
|
||||||
|
|
||||||
// return an orderly object
|
// return an orderly object
|
||||||
return {
|
return {
|
||||||
image: {
|
image: {
|
||||||
|
@ -219,6 +231,9 @@ const utils = (() => {
|
||||||
cors: {
|
cors: {
|
||||||
rewriteUrl,
|
rewriteUrl,
|
||||||
},
|
},
|
||||||
|
fetch: {
|
||||||
|
json,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue