javascript - 无法解决致命异常:无法将消息的值从 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
};
我需要修复崩溃。
解决方案
推荐阅读
- excel - 有没有办法不包含索引值,以便它可以在 Excel 中搜索下一个索引出现
- python - 根据排名替换数据框中的值
- r - 根据两个条件创建id
- c# - 使用 Microsoft.Identity.Web 1.60 调用 Microsoft Graph 时出现 System.NullReferenceException
- maximo - 使用 WOTotalSet 填充 WORKORDER 字段
- python - 我无法从内部模块文件中导入模块
- html - 如何定位
Vue3中父级CSS规则的内容? - typescript - 执行 npm run build 时如何使用 sequelize 修复此错误?
- javascript - 使用 js load 重新加载多个表的内容,但传输了 php 变量/数组
- powershell - 使用 PowerShell 在 Internet Explorer 中按“另存为”按钮