Reputation: 911
Okay i got a kind of special problem just with react native i think
Here is the code
login(){
fetch('http://52.28.212.104:8081/milltimeLogin', {
method: 'POST',
headers: {
'Authorization':"basic " + this.state.username + ":" + this.state.passw ,
},
}).then(response => response.text())
.then(text => {
console.log(text['mta:loginResponse']);
})
}
this exact log works in reactjs but not in react native the reason that i have the ['mta:...'] is that the response has the mta: tags so i have to use [''] but i doesnt seem to work in react native. if i just log text i get the whole response but i need to get specific parts of it. Anyone know how to do this in react native?
Upvotes: 2
Views: 51
Reputation: 163
Instead of using simple console.log command
Use Reactoron for Logging Data Here is the link: https://github.com/infinitered/reactotron
Best thing for log
Upvotes: 0
Reputation: 22797
I think you can make it work this way, read it as json
object except of text
.
login(){
fetch('http://52.28.212.104:8081/milltimeLogin', {
method: 'POST',
headers: {
'Authorization':"basic " + this.state.username + ":" + this.state.passw ,
},
}).then(response => response.json())
.then(json => {
console.log(json['mta:loginResponse']);
})
}
Upvotes: 1