I will check how it works.
function jsonToGeoJson() {
fetch(api, {
method: "GET",
headers: { 'x-openaip-client-id': 'xyz...' }
})
.then(response => response.json())
.then(json => {
const jsonItem = json.items;
// for each json.item add features
let features = [];
jsonItem.forEach((item, index, itemArray) => {
const feature = {
"type": "Feature",
"properties": item,
"geometry": item.geometry
}
features.push(feature);
});
const geoJson = { "type": "FeatureCollection", "features": features };
console.log(geoJson); // final result
})
.catch(error => console.log(error));