首页 > 解决方案 > 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))
  });
}

标签: javascriptnode.js

解决方案


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


推荐阅读