React Native Snippets
Test HTTPS request
//function* signIn(action) {
fetch("https://url/auth/token")
.then((response) => {
return response.text()
})
.then((responseJson) => {
console.log(responseJson)
Alert.alert("test ok", responseJson)
})
.catch((error) => {
Alert.alert("test error", error)
console.error(error)
})
var request = new XMLHttpRequest()
request.onreadystatechange = (e) => {
if (request.readyState !== 4) {
return
}
if (request.status === 200) {
Alert.alert("test ok2", request.responseText)
console.log("success", request.responseText)
} else {
Alert.alert("test error2", JSON.stringify(request))
console.warn("error", request)
}
}
request.open("GET", "https://url/auth/token")
request.send()