Now checks the return status for if it was a success or not.

This commit is contained in:
2018-01-09 22:49:59 +01:00
parent fe020faf21
commit 159de6527c

View File

@@ -44,10 +44,16 @@ class PirateSearch extends Component {
fetchJSON('https://apollo.kevinmidboe.com/api/v1/pirate/search?query='+query+'&type='+type, 'GET') fetchJSON('https://apollo.kevinmidboe.com/api/v1/pirate/search?query='+query+'&type='+type, 'GET')
// fetchJSON('http://localhost:31459/api/v1/pirate/search?query='+query+'&type='+type, 'GET') // fetchJSON('http://localhost:31459/api/v1/pirate/search?query='+query+'&type='+type, 'GET')
.then((response) => { .then((response) => {
console.log('this is the first response: ', response)
if (response.success === true) {
this.setState({ this.setState({
torrentResponse: response.torrents, torrentResponse: response.torrents,
loading: null, loading: null,
}) })
}
else {
console.error(response.message)
}
}) })
.catch((error) => { .catch((error) => {
console.error(error); console.error(error);