有没有办法在 iOS 上的 React Native 中获取底层 NSURLErrorDomain (代码)?
在我们的 React Native 应用程序中,我们使用 TrustKit 在 iOS 上进行证书固定。如果证书验证失败并且我在 JavaScript 上下文中捕获错误(如下例),则记录错误仅显示一般错误消息:TypeError: Network request failed
。
由于错误不是源于 http 状态代码,例如 404
,我相信我需要检查 NSURLErrorDomain
代码(例如)这样我就可以用正确的错误处理来映射它。 React Native、fetch
、axios
或其他包中是否有任何 API 可以提供对这些错误详细信息的访问?
fetch(myURL).then(() => true, (error) => {
console.log(error) //TypeError: Network request failed
return false;
})
In our React Native app we use TrustKit for certificate pinning on iOS. If the certificate validation fails and I catch the error within the JavaScript context (example below), logging the error only shows a generic error message: TypeError: Network request failed
.
Since the error doesn't stem from an http status code, like 404
, I believe I need to inspect the NSURLErrorDomain
code (for example) so that I can map it with the correct error handling. Are there any APIs in React Native, fetch
, axios
, or another package that would provide access to these error details?
fetch(myURL).then(() => true, (error) => {
console.log(error) //TypeError: Network request failed
return false;
})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论