I would guess you are getting the Console Log for “this.responseText”… so that would need to be parsed as JSON and then included in your L.geoJSON(???).addTo(map);
let request = new XMLHttpRequest();
request.open('POST', "https://api.openrouteservice.org/v2/directions/driving-hgv/geojson");
request.setRequestHeader('Accept', 'application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8');
request.setRequestHeader('Content-Type', 'application/json');
request.setRequestHeader('Authorization', 'API_KEY');
request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log('Status:', this.status);
console.log('Headers:', this.getAllResponseHeaders());
console.log('Body:', this.responseText);
var json = JSON.parse(this.responseText)
L.geoJSON(json).addTo(map);
}
};
const body = '{"coordinates":[[11.0419554,49.5939908],[11,49.6],[11.0393399,49.594125]],"attributes":["detourfactor","percentage"]}';
request.send(body);