Looking for the best way to access the data returned from an api call. The string looks like this:
'https://somedomain/data.json?callback=someCallback'
and I fetch like this:
fetch('https://somedomain/data.json?callback=someCallback')
.then(response => response.text())
.then(text => console.log(text));
and this will give me the data that I need but it wrapped up in the callback like so:
someCallback({/* json like data here */})
I know the returned data is a stream because if I do soemthing like this:
.then(response => {
const reader = response.body.getReader();
console.log(reader);
});
I get back this:
ReadableStreamDefaultReader {closed: Promise}
Ideally I would like this data in the form of a json object so how would I go about getting that. Or if that is just bad practice how to read this?