0

I'm using the fetch API to get some JSON data I want to work with:

function getMarkes() {
    return fetch(url, { headers: { "Content-Type": "application/json; charset=utf-8", 'Accept': 'application/json' } })
        .then(response => response.json())
}

This is the data that gets returned by the call:

["2",[{"id":"1","title":"title","lat":"52.011544629651524","long":"9.974744319915771"},{"id":"6","title":"title","lat":"51.3459148340574","long":"12.363418747546348"},{"id":"5","title":"title","lat":"52.48111410935233","long":"13.517611467320194"},{"id":"9","title":"title","lat":"51.6640392982322","long":"9.7315917652179"},{"id":"8","title":"title","lat":"52.516952093701605","long":"13.463058471679688"}]]

When outputting it here I only get a "2", not the whole JSON object.

getMarkes()
    .then(([markers]) => {
        console.log(markers);
    })

When outputting it in the getMarkes Promise itself I get the whole JSON object.

Mike
  • 4,562
  • 3
  • 31
  • 60

0 Answers0