如何修复 java.lang.Double 在 React Native 中无法转换为 java.lang.String

Dev*_*vGe 4 react-native

我的 AsyncStorage.getItem 有问题。我有一个登录模块,我需要在存储中设置项目,在我得到结果后,下面有一条黄色消息,我有错误:java.lang.Double cannot be cast to java.lang.String I不知道哪里出错了。

错误

我会告诉你们,我在存储中设置项目的功能。

     if(response.status == '200')
     {
          AsyncStorage.setItem('authorization_code',access_token);
          AsyncStorage.setItem('authorization_expiration',expires_in);
          AsyncStorage.setItem('authorization_type',token_type);

          //let token = AsyncStorage.getItem(JSON.stringify("authorization_code"));
           AsyncStorage.getItem('authorization_code', (err, result) => {
            alert(result);
          });

     }
Run Code Online (Sandbox Code Playgroud)

isa*_*iro 8

用于toString()在 js 端强制输入。我想这是expires_in这里的浮点数,所以:

          AsyncStorage.setItem('authorization_code',access_token);
          AsyncStorage.setItem('authorization_expiration',expires_in.toString());
          AsyncStorage.setItem('authorization_type',token_type);
Run Code Online (Sandbox Code Playgroud)