简体   繁体   中英

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.

在此处输入图片说明

if i change like that

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

the result is

在此处输入图片说明

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM