Loading data in the browser without jQuery.
dbauszus-glx opened this issue · 2 comments
dbauszus-glx commented
I am trying to load data in the browser as outline in the documentation.
I use xhr requests pretty much every day and never had a problem with the structure.
let xhr = new XMLHttpRequest();
xhr.open('GET', 'http://matrix.mapzen.com/isochrone?json={%22locations%22:[{%22lat%22:52.62972886718355,%22lon%22:-1.0107421875000002}],%22costing%22:%22multimodal%22,%22contours%22:[{%22time%22:45}]}&api_key=xxx');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onload = function () {
if (xhr.status === 200) {
console.log(xhr.responseText);
}
};
xhr.send();
Yet, the Mapzen API throws me {"error_code":101,"error":"Try a POST or GET request instead","status_code":405,"status":"Method Not Allowed"}.
I do use 'GET', so I am not sure what can be done here. Surely there must be a way to use the API without jQuery or Angular?
dbauszus-glx commented
Looks like this is working when I comment the content-type request header.
//xhr.setRequestHeader('Content-Type', 'application/json');
rmglennon commented
This came in through support for Matrix, too (see Desk 1075).
As in the comment, this will work without the xhr.setRequestHeader line for a GET request.