在我的react-native应用程序中,我需要stringify(序列化)大对象而不是阻塞js线程 - 使用另一个线程的异步api,如下所示:
JSON.stringifyAsync({ foo: "bar" }).then(x => console.log(x));
Run Code Online (Sandbox Code Playgroud)
请不要建议将JSON.stringify包装到Promise中,它只是推迟阻塞js线程.
ApolloError
有networkError属性,但当服务器响应 4** 或 5** 状态代码时设置它。
以及如何检查问题是否是由网络连接不良引起的?
try {
apolloClient.query(someQuery)
} catch (error) {
if (isInternetConnectionError(error)) { // how to check this?
Alert.alert('Please check your internet connection!')
} else {
logException(error);
}
}
Run Code Online (Sandbox Code Playgroud) javascript exception internet-connection apollo apollo-client