javascript - Http调用Node.js问题,socket挂断错误
问题描述
我遇到了以下问题,所有通过 axios 的 HTTP 调用都可以正常工作,没有任何问题,几个小时后,所有调用都返回了以下错误:
socket hang up error
奇怪的是,来自 Postman 的相同调用没有问题,我想知道你们中是否有人遇到同样的问题以及如何解决它,这是我正在使用的代码:
const getToken = async (username, password) => {
try {
const body = {username, password}
const url = `${API_URI.auth}`
const options = {
method: 'POST',
url,
headers: {
'Content-Type': 'application/json'
},
data: JSON.stringify(body)
}
const response = await axios(options).then((res) => res.data.json())
console.log(response)
return response
} catch (error) {
console.log(error.message)
return false
}
}
解决方案
推荐阅读
- c# - TreeView 检测节点选择,但在选中或取消选中时不检测
- c++ - if 函数的另一种解决方案,减少写作
- r - 根据列表位置绑定列表列表
- amazon-web-services - S3 lambda 上传问题:管道损坏
- javascript - 在 JavaScript 中使用 fetch 通过 Twitter API 的 Auth1.0a
- reactjs - Spring Boot Rest Controller POST 请求总是使用@SessionScope 创建新的 sessionid?
- python - 如果多个元素具有相同的优先级,python中是否存在“Lifo”类型的优先级队列?
- android - Kotlin 简单列表视图删除行
- xamarin - 在 Xamarin.Forms Shell 中使用 ShellSection 时,为什么在弹出窗口中不显示分隔符?
- javascript - 3选择将id发送给laravel 8中的其他选择