I'm trying to use this API https://www.petfinder.com/developers/api-docs with React Native. The problem I'm having is it returns JSONP rather than JSON so using fetch is giving me an unexpected token in JSON error. I've tried to use a library like fetch-jsonP, however thats not working in React Native because there is no document (same with jquery), any ideas how I can get jsonP data with React Native?
App.js
class Home extends Component {
componentDidMount() {
fetch(
`http://api.petfinder.com/pet.find?format=json&key=${API_KEY}&animal=dog&location=84070&callback=callback`
)
.then(res => res.json())
.then(responseText => console.log(responseText))
.catch(err => console.log(err));
}
render() {
const width = Dimensions.get("window").width;
const height = Dimensions.get("window").height;
return (
<View>
<Header
backgroundColor={darkBlue}
leftComponent={{ icon: "menu", color: "#fff" }}
centerComponent={<HeaderTextComponent />}
rightComponent={{ icon: "home", color: "#fff" }}
/>
</View>
);
}
}
export default Home;