为什么节点请求-不工作,但是wget-工作?

时间:2020-04-17 12:33:37

标签: node.js debian wget debian-buster

说什么负责Node中的HTTP请求? 为什么通过命令行wget的请求有效,而通过Node中的请求却无效?

我在Node中使用了所有三种最受欢迎​​的库请求axios,fetch + standard get请求。

axios.get('https://api.com/json', {timeout: 2000})
  .then(function (response) {})
  .catch(function (error) {}) // I have timeout error

但是来自cli的要求

wget -qO - --timeout=2 --waitretry=0 --tries=1 "https://api.com/json"

这是一个非常奇怪的Node行为,就像阻止传出请求一样。

~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 10 (buster)
Release:        10
Codename:       buster

~# node -v
v12.13.1

~# npm -v
6.12.1

请告诉我要查找哪个日志以找出问题?

0 个答案:

没有答案