【发布时间】:2021-09-14 07:38:27
【问题描述】:
有人可以提供 cURL --resolve 等效于 NodeJS 中的以下请求-
curl http://www.example.com --resolve www.example.com:80:127.0.0.1
输出:
cURL 在终端中工作,但我需要使用 NodeJS 为我的应用程序执行类似的请求。
关注的文章:CURL --resolve in node.js axios 但这也给了我 404 Not Found 错误:
Debugger attached.
(node:33104) UnhandledPromiseRejectionWarning: Error: Request failed with status code 404
at createError (/home/anish/Desktop/SampleWeb/node_modules/axios/lib/core/createError.js:16:15)
at settle (/home/anish/Desktop/SampleWeb/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/home/anish/Desktop/SampleWeb/node_modules/axios/lib/adapters/http.js:269:11)
at IncomingMessage.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
(node:33104) 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(). (rejection id: 2)
(node:33104) [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.
Waiting for the debugger to disconnect...
Waiting for the debugger to disconnect...
我尝试过其他 stackoverflow 问题,但没有一个解决方案看起来很有希望。
【问题讨论】: