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

React native 如何修复java.lang.Double无法在React Native中转换为java.lang.String,react-native,React Native,关于AsyncStorage.getItem,我有问题。我有一个模块,它是登录名,我需要在存储中设置项目,在我得到结果后,下面有一条黄色消息,我有错误:java.lang.Double不能转换为java.lang.String,我不知道错误来自何处 我将向你们展示我在存储器中设置项目的功能 if(response.status == '200') { AsyncStorage.setItem('authorization_code',access_tok

关于AsyncStorage.getItem,我有问题。我有一个模块,它是登录名,我需要在存储中设置项目,在我得到结果后,下面有一条黄色消息,我有错误:java.lang.Double不能转换为java.lang.String,我不知道错误来自何处

我将向你们展示我在存储器中设置项目的功能

     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);
          });

     }
使用
toString()
强制在js端键入。我想这里的浮点数是
expires\u,所以:

          AsyncStorage.setItem('authorization_code',access_token);
          AsyncStorage.setItem('authorization_expiration',expires_in.toString());
          AsyncStorage.setItem('authorization_type',token_type);

此问题是由于数据类型错误引起的。使用异步存储后,必须仅存储字符串数据类型。如果存储int,它将传递此错误。所以您可以在源代码末尾使用
.toString()

AsyncStorage.setItem('userId', response.data.dataset[0].id.toString());

另请参见Java标记已删除,看起来不像Java代码。也许你指的是Javascript?我得到了反向错误,因为
String
无法转换为
java.lang.Double
,我在这里缺少什么?