I have an API which needs headers to allow access.
It requires 3 types of header, and without them, in a browser you see
Code: 4101
Message: Header X-Candy-Platform is required
But when you have the headers you get a json. Im trying to get the Json in react Native using this
getPostsFromApiAsync(number) {
    return fetch('http://THEAPI?api_key=APIKEY', {method: 'GET', headers: {
                'x-candy-platform': 'desktop',
                'x-candy-audience': 'domestic',
                accept: 'application/json'
            }})
        .then((response) => response.json())
        .then((responseJson) => {
            var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 != r2})
            this.setState({peopleDataSource: ds.cloneWithRows(responseJson)});
        })
        .catch((error) => {
            console.error(error);
        });
}
However this gets me Network request failed.
If I have a file inside 'fetch' which is local, it works fine.
The Three headers required are
x-candy-platform - desktop
x-candy-audience - domestic
Accept - application/json
Any ideas? Thanks
 
    