网络请求失败 Expo Fetch
Network Request Failed Expo Fetch
我目前在尝试向我的 API 发出请求并检索结果时遇到有关获取功能的问题。这种情况以前没有发生过,几周前才开始出现这种情况。这是我收到的错误。
[Unhandled promise rejection: TypeError: Network request failed]
- node_modules/whatwg-fetch/dist/fetch.umd.js:535:17 in setTimeout$argument_0
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:130:14 in _callTimer
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:383:16 in callTimers
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:416:4 in __callFunction
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:109:6 in __guard$argument_0
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:364:10 in __guard
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:108:4 in callFunctionReturnFlushedQueue
* [native code]:null in callFunctionReturnFlushedQueue
这是一个提取请求的示例,我 运行 从 API 检索数据。在 Postman 上发出这个请求确实给了我结果,正如一开始提到的,它以前也给过我结果。
getButtons(token) {
fetch('https://**.**.org/api/v1/requests/***', {
method: 'POST',
headers: {
'token' : this.state.token,
// 'deviceCode' : this.state.device_code,
'qrvalue' : this.state.qr_value,
},
body: JSON.stringify({
'token' : this.state.token
})
}).then(response => response.json().then(data =>({
data: data,
status: response.status
})
).then(res => {
this.setState({
buttons: res.data.options
});
this.renderButtons();
}));
}
欢迎提出任何建议
问题是 API 的 SSL 证书已过期,这意味着请求是通过 HTTP 而不是 HTTPS 进行的。续订证书允许请求通过 HTTPS,这已解决问题。
我目前在尝试向我的 API 发出请求并检索结果时遇到有关获取功能的问题。这种情况以前没有发生过,几周前才开始出现这种情况。这是我收到的错误。
[Unhandled promise rejection: TypeError: Network request failed]
- node_modules/whatwg-fetch/dist/fetch.umd.js:535:17 in setTimeout$argument_0
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:130:14 in _callTimer
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:383:16 in callTimers
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:416:4 in __callFunction
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:109:6 in __guard$argument_0
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:364:10 in __guard
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:108:4 in callFunctionReturnFlushedQueue
* [native code]:null in callFunctionReturnFlushedQueue
这是一个提取请求的示例,我 运行 从 API 检索数据。在 Postman 上发出这个请求确实给了我结果,正如一开始提到的,它以前也给过我结果。
getButtons(token) {
fetch('https://**.**.org/api/v1/requests/***', {
method: 'POST',
headers: {
'token' : this.state.token,
// 'deviceCode' : this.state.device_code,
'qrvalue' : this.state.qr_value,
},
body: JSON.stringify({
'token' : this.state.token
})
}).then(response => response.json().then(data =>({
data: data,
status: response.status
})
).then(res => {
this.setState({
buttons: res.data.options
});
this.renderButtons();
}));
}
欢迎提出任何建议
问题是 API 的 SSL 证书已过期,这意味着请求是通过 HTTP 而不是 HTTPS 进行的。续订证书允许请求通过 HTTPS,这已解决问题。