javascript - Windows 10 Unable to access xxx.local domain via nodeJS
问题描述
I'm getting an error on my Windows machine but not my mac on the same network. Any idea?
(node:16940) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'data' of undefined
at E:\xxx.js:28:47
at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:16940) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id:
2)
(node:16940) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
function checkNumSatoshis(JWTToken, qrcode) {
return new Promise((resolve, reject) => {
axios.get(
`http://xxx.local/api/v1/xx/xx/invoice?paymentRequest=${qrcode}`,
{
headers: {
Authorization: `JWT ${JWTToken}`,
},
}
)
.then((res) => resolve(res.data.xx))
.catch((error) => reject(error.response.data))
});
}
解决方案
Add 192.168.1.x xx.local to your C:\WINDOWS\System32\drivers\etc\hosts fixed. I entered the correct format in the host file
推荐阅读
- windows - %%Errorlevel%% 在使用导向器时即使有额外的 % 仍然会变为 0
- isabelle - 在 Isabelle 中计算关系运算符时如何处理“引发异常匹配”?
- oauth-2.0 - 新的访问令牌请求使 WSO2 IS 中的所有先前令牌无效
- javascript - 无法更新 keyDown 上的状态挂钩
- r - 无法运行 usethis::use_vignette
- c++ - 在 C++ 中实现 zip 和 unzip。我对 char* 缓冲区感到困惑
- amazon-web-services - AWS ECR 用户无权执行:ecr-public:GetAuthorizationToken 对资源:*
- java - Java 递归问题 - 打印时出现重复
- javascript - Javascript - 如何组合 2 个字符串,以便结果是现有变量的名称 - 而不仅仅是一个新字符串..?
- python - 从 Python 中的列表中提取元素以创建嵌套列表