React Native Fetch无法解析或拒绝API请求

时间:2018-11-06 22:07:42

标签: react-native fetch

我总是在浏览器控制台中从此请求得到正确的响应:

fetch('http://178.62.66.29:8080/api/v1/auth/1/2', {
    method: "GET",
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
    },
})
    .then(response => response.json())
    .then(responsejson =>  console.log(responsejson))
    .catch(err => console.error(err));

但是当我在React native(Android)中使用完全相同的代码时,fetch函数不会解析或拒绝任何东西。问题是,有时fetch函数起作用(如1/10),这使我更加困惑这个问题。

0 个答案:

没有答案