I am using this way it is working fine.
fetch('https://facebook.github.io/react-native/movies.json')
.then((response) => response.text())
.then((responseText) => {
console.log(JSON.parse(responseText));
})
.catch((error) => {
console.log("reset client error-------",error);
});
Below is used for particular method request. Headers and Body are used for send data to server. For this way we can request type and method for fetch function.
fetch(url, {
method: 'POST',
timeout:10000,
headers: headers,
body: JSON.stringify(params)
})
.then((response) => response.text())
.then((responseText) => {
console.log(JSON.parse(responseText));
})
.catch((error) => {
console.log("reset client error-------",error);
});
});