首页 > 解决方案 > 无法解决致命异常:无法将消息的值从 ReadableNativeMap 转换为字符串

问题描述

我的反应本机应用程序不断收到此错误。致命异常:java.lang.ClassCastException:消息的值不能从 ReadableNativeMap 转换为 String 它不经常出现。但是大约 %10 的用户得到了它。

我认为问题出在json上。但我不确定。

async function getCountry() {
  try {
    let response = await fetch(
      'http://ip-api.com/json/?fields=country',
    );
    let responseJson = await response.json();
    return responseJson;
  } catch (error) {
    console.error(error);
  }
}
 let countryName="";
    await getCountry().then((data)=> { countryName= data.country}).catch(()=> countryName="")


    var user = {
      _id : "user:"+email,
      name: name,
      photo: image,
      email: email,
      country:countryName
      };

我需要修复崩溃。

标签: javascriptandroidreactjsreact-native

解决方案


推荐阅读