React Native-获取未捕获无效的URL错误

时间:2020-05-14 00:14:46

标签: react-native axios fetch

指定无效网址时,

抓取不会捕获错误,例如:

try {
    fetch('exampleInvalidUrl.com')
        .then(response => response.json())
        .then(responseJSON => responseJSON.map(object => object))
    }
    catch {
        console.log('error') // this should throw an error but it doesn't
    }

我该如何解决? //此示例仅不会在react-native应用上引发错误

0 个答案:

没有答案
相关问题