박형렬
박형렬

Reputation: 397

how to get element in arrarys at react-native?

this is my code

function kakaoLogin() {
  RNKakaoLogins.login((err, result) => {
    Alert.alert("token", result);}}

the result is below picture.

enter image description here

if i change like that

function kakaoLogin() {
      RNKakaoLogins.login((err, result) => {
        Alert.alert("token", result.token);}}

the result is

enter image description here

why it doesn't get token value? how do i get the token value?

Upvotes: 0

Views: 55

Answers (1)

Patryk Brejdak
Patryk Brejdak

Reputation: 1601

I'm 99% sure, that your result is stringified, so thats why you have {token: ... }, you should firstly parse response then try to show it.

const response = JSON.parse(result);
Alert.alert("token", response.token); // now response is parsed object and property toke is accessible

Upvotes: 1

Related Questions