[英]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. 我有99%的肯定,您的结果是字符串化的,因此,这就是您拥有
{token: ... }
,您应该首先分析响应,然后尝试显示它。
const response = JSON.parse(result);
Alert.alert("token", response.token); // now response is parsed object and property toke is accessible
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.