2016-10-20 2 views
-1

이 코드를 사용하여 URL을 호출했으며 네트워크 요청이 실패했습니다. 그러나 abc.com/types와 같은 지정된 도메인으로 IP 주소를 바꾸면. 누구나 왜 고쳐야하는지 알고 있습니까?네트워크 요청 실패 네이티브 기본

fetch("192.168.1.99/SP/public/api/types") 
      .then((response) => response.json()) 
      .then((responseJSON) => { 
       console.log(responseJSON); 
       if (responseJSON.code == 200) { 
        console.log("OK: " + responseJSON.result); 
       } else { 
        console.log("FAIL: " + responseJSON.message); 
       } 
      }).catch((error) => { 
      console.log(error); 
     }); 

Ps : 이미 AppTransportSecuritySetting을 설정했습니다.

+0

HTTP를 추가 : // 해결 문제 – maphongba008

답변

1

누락 된 프로토콜에 http : //

fetch("http://192.168.1.99/SP/public/api/types") 
       .then((response) => response.json()) 
       .then((responseJSON) => { 
        console.log(responseJSON); 
        if (responseJSON.code == 200) { 
         console.log("OK: " + responseJSON.result); 
        } else { 
         console.log("FAIL: " + responseJSON.message); 
        } 
       }).catch((error) => { 
       console.log(error); 
      });