Hello,
I’m trying to use javascript fetch() to load the data from a gpx file in order to display it in leaflet.
let osm_server_load_gpx = function (id) {
let n = "Bearer " + localStorage.getItem("openstreetmap_token");
const myHeaders = new Headers({
Authorization: n,
});
return fetch("https://api.openstreetmap.org/api/0.6/gpx/" + id + "/data", {
method: "GET",
headers: myHeaders,
redirect: "follow",
})
.then((response) => response.text())
.then((data) => {
console.log("data:" + data);
/*
new L.GPX(data, {
async: true,
})
.on("loaded", function (e) {
map.fitBounds(e.target.getBounds());
})
.addTo(map);
*/
})
.catch((error) => {
alert("error: " + error);
});
};
However, I get a 302 error, is it only possible to download the file with the API endpoint or also to load the data of the file?
https://wiki.openstreetmap.org/wiki/API_v0.6#Download_Data:GET.2Fapi.2F0.6.2Fgpx.2F.23id.2Fdata
Greetings perry