React native API在postman中返回200,但在设备中返回404 我已经使用我的应用程序使用膝关节炎和PostgreSQL数据库创建了一个简单的API,并使用Postman和浏览器进行了测试,两者都很好。现在,我尝试在我的react本机应用程序(在实际设备上测试)中获取数据,但它向我返回以下响应: {"_bodyBlob": {"_data": {"__collector": [Object], "blobId": "1bbc1ba3-a1b4-442e-ba85-d09d5d54f4e6", "offset": 0, "size": 9}}, "_bodyInit": {"_data": {"__collector": [Object], "blobId": "1bbc1ba3-a1b4-442e-ba85-d09d5d54f4e6", "offset": 0, "size": 9}}, "headers": {"map": {"content-length": "9", "content-type": "text/plain; charset=utf-8", "date": "Mon, 20 Apr 2020 12:26:12 GMT"}}, "ok": false, "status": 404, "statusText": undefined, "type": "default", "url": "https://a1cd97c8.ngrok.io/posts/,function%20dispatchAction()%20%7B%20%20%20%20[native%20code]%7D"}

React native API在postman中返回200,但在设备中返回404 我已经使用我的应用程序使用膝关节炎和PostgreSQL数据库创建了一个简单的API,并使用Postman和浏览器进行了测试,两者都很好。现在,我尝试在我的react本机应用程序(在实际设备上测试)中获取数据,但它向我返回以下响应: {"_bodyBlob": {"_data": {"__collector": [Object], "blobId": "1bbc1ba3-a1b4-442e-ba85-d09d5d54f4e6", "offset": 0, "size": 9}}, "_bodyInit": {"_data": {"__collector": [Object], "blobId": "1bbc1ba3-a1b4-442e-ba85-d09d5d54f4e6", "offset": 0, "size": 9}}, "headers": {"map": {"content-length": "9", "content-type": "text/plain; charset=utf-8", "date": "Mon, 20 Apr 2020 12:26:12 GMT"}}, "ok": false, "status": 404, "statusText": undefined, "type": "default", "url": "https://a1cd97c8.ngrok.io/posts/,function%20dispatchAction()%20%7B%20%20%20%20[native%20code]%7D"},react-native,koa,React Native,Koa,我使用ngrok URL映射,因为如果没有https,我的请求会被直接拒绝 以下是我的请求代码: const searchURL = React.useState('https://a1cd97c8.ngrok.io/posts/'); const fetchPosts = async () => { console.log('fetching'); fetch(searchURL, { method: 'GET',

我使用ngrok URL映射,因为如果没有https,我的请求会被直接拒绝

以下是我的请求代码:

const searchURL = React.useState('https://a1cd97c8.ngrok.io/posts/');    
const fetchPosts = async () => {
        console.log('fetching');
        fetch(searchURL, {
          method: 'GET',
          headers: {
            Accept: 'application/json',
            'Content-Type': 'application/json',
          },
        })
          .then((response) => {
            console.log('response: ', response);
            return response.json();
          })
          .then((json) => console.log('TESTOUTPUT', json))
          .catch((err) => console.log('error: ', err.message));
      };
我在catch块中得到的错误消息是:

error:  JSON Parse error: Unexpected identifier "Not"

我做错了什么?

useState
hook返回一个数组,因此应该对结果进行分解

const [searchURL, setSearchURL] = React.useState('https://a1cd97c8.ngrok.io/posts/');

useState
hook返回一个数组,因此应该对结果进行分解

const [searchURL, setSearchURL] = React.useState('https://a1cd97c8.ngrok.io/posts/');

这让我发疯,我认为这是一个API问题。谢谢这让我发疯了,我还以为这是API的问题呢。非常感谢。