windows 10无法通过nodejs访问.local域

50few1ms  于 2021-09-23  发布在  Java
关注(0)|答案(2)|浏览(301)

我在windows计算机上出错,但在同一网络上的mac电脑上没有。有什么想法吗?

  1. (node:16940) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'data' of undefined
  2. at E:\xxx.js:28:47
  3. at processTicksAndRejections (internal/process/task_queues.js:95:5)
  4. (Use `node --trace-warnings ...` to show where the warning was created)
  5. (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:
  6. 2)
  7. (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.
  1. function checkNumSatoshis(JWTToken, qrcode) {
  2. return new Promise((resolve, reject) => {
  3. axios.get(
  4. `http://xxx.local/api/v1/xx/xx/invoice?paymentRequest=${qrcode}`,
  5. {
  6. headers: {
  7. Authorization: `JWT ${JWTToken}`,
  8. },
  9. }
  10. )
  11. .then((res) => resolve(res.data.xx))
  12. .catch((error) => reject(error.response.data))
  13. });
  14. }
uidvcgyl

uidvcgyl1#

将192.168.1.x xx.local添加到c:\windows\system32\drivers\etc\hosts中。我在主机文件中输入了正确的格式

mwg9r5ms

mwg9r5ms2#

设置请求时出错,因此承诺转到catch块。然而, error.responseundefined 因为没有提出任何要求。
改为执行以下操作以获取有关此错误的更多信息:

  1. .catch((error) => { console.log(error)})

相关问题