I have a local api in eclipse and I'm using tomcat I'm trying to use it with XMLHttpRequest in react-native and I'm not always getting error request.
onPressButtonAtualizarBanco=() => {
var request = new XMLHttpRequest();
request.onreadystatechange = (e) => {
if (request.readyState !== 4) {
return;
}
if (request.status === 200) {
console.log('success', request.responseText);
} else {
console.warn('error');
}
};
request.open('GET', 'http://localhost:8080/Restful/cliente/brinddata');
request.send();
}
The api data is returning in xml so I am using the XMLHttpRequest