As I embark on my journey with react-native, I have chosen the classic example found in the documentation as my starting point...
fetch('https://facebook.github.io/react-native/movies.json')
.then((response) => response.json())
.then((responseJson) => {
return responseJson.movies;
})
.catch((error) => {
console.error(error);
});
Everything seems to be working well when dealing with proper JSON data in this example.
However, in the scenario specific to my project, the API only provides JSONP responses and not plain JSON. There is no basic JSON available, so an error related to the "(" character arises.
Instead of receiving structured JSON like
{"id": "1", "movies" : [ { "id" : "123" } ] }
I am presented with JSONP format like
?( {"id": "1", "movies" : [ { "id" : "123" } ] });
Given this situation, I'm uncertain about how to extract the JSON content using fetch promises. Is there a way for me to manipulate the response using my own functions, or perhaps a more seamless approach?
In the first then() block, I am puzzled about how to access the actual JSON data (I've attempted working with the response, but it appears to refer to the promise itself, leaving me unsure about how react-native fetch handles such scenarios).