let data = fetch('http://mylocalapi.test/api/query?resource=article')
.then((response) => {
console.log("Get Data");
console.log(response);
this.setState({articles:JSON.parse(response._bodyInit)});
});
响应返回以下内容。它似乎试图将我重定向到dnssearch.com,因为它无法找到我的rul。我的网址是一个实际的测试域。
我使用genymotion
作为模拟器并使用Expo
12:16:23: Response {
12:16:23: "_bodyInit": "<html><head><meta http-equiv=\"refresh\" content=\"0;url=http://www.dnsrsearch.com/index.php?origURL=http://whatshapp.test/api/query&bc=\"/></head><body><script type=\"text/javascript\">window.location=\"http://www.dnsrsearch.com/index.php?origURL=\"+escape(window.location)+\"&r=\"+escape(document.referrer)+\"&bc=\";</script></body></html>",
12:16:23: "_bodyText": "<html><head><meta http-equiv=\"refresh\" content=\"0;url=http://www.dnsrsearch.com/index.php?origURL=http://whatshapp.test/api/query&bc=\"/></head><body><script type=\"text/javascript\">window.location=\"http://www.dnsrsearch.com/index.php?origURL=\"+escape(window.location)+\"&r=\"+escape(document.referrer)+\"&bc=\";</script></body></html>",
12:16:23: "headers": Headers {
12:16:23: "map": Object {
12:16:23: "cache-control": Array [
12:16:23: "public, max-age=0",
12:16:23: ],
12:16:23: "connection": Array [
12:16:23: "close",
12:16:23: ],
12:16:23: "content-type": Array [
12:16:23: "text/html",
12:16:23: ],
12:16:23: "date": Array [
12:16:23: "Fri, 30 Mar 2018 16:15:49 GMT",
12:16:23: ],
12:16:23: "expires": Array [
12:16:23: "Fri, 30 Mar 2018 16:15:48 GMT",
12:16:23: ],
12:16:23: "server": Array [
12:16:23: "nginx",
12:16:23: ],
12:16:23: "transfer-encoding": Array [
12:16:23: "chunked",
12:16:23: ],
12:16:23: "vary": Array [
12:16:23: "Accept-Encoding",
12:16:23: ],
12:16:23: },
12:16:23: },
12:16:23: "ok": true,
12:16:23: "status": 200,
12:16:23: "statusText": undefined,
12:16:23: "type": "default",
12:16:23: "url": "http://whatshapp.test/api/query?resource=article",
12:16:23: }