Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/376.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 点头。TypeError:https.request不是函数_Javascript_Node.js_Angularjs - Fatal编程技术网

Javascript 点头。TypeError:https.request不是函数

Javascript 点头。TypeError:https.request不是函数,javascript,node.js,angularjs,Javascript,Node.js,Angularjs,我正在用AngularJS编写一个web应用程序,由于CORS问题,我使用NodeJS。嗯,当我试图在我的节点中发出请求时,会出现以下错误: TypeError: https.request is not a function at C:\Users\Usuario\eclipse-workspace\AgriWea\WebContent\js\index.js:56:22 at Layer.handle [as handle_request] (C:\Users\Usuario\eclipse

我正在用AngularJS编写一个web应用程序,由于CORS问题,我使用NodeJS。嗯,当我试图在我的节点中发出请求时,会出现以下错误:

TypeError: https.request is not a function
at C:\Users\Usuario\eclipse-workspace\AgriWea\WebContent\js\index.js:56:22
at Layer.handle [as handle_request] (C:\Users\Usuario\eclipse-workspace\AgriWea\WebContent\js\node_modules\express\lib\router\layer.js:95:5)
at next (C:\Users\Usuario\eclipse-workspace\AgriWea\WebContent\js\node_modules\express\lib\router\route.js:137:13)
at cors (C:\Users\Usuario\eclipse-workspace\AgriWea\WebContent\js\node_modules\cors\lib\index.js:188:7)
at C:\Users\Usuario\eclipse-workspace\AgriWea\WebContent\js\node_modules\cors\lib\index.js:224:17
at originCallback (C:\Users\Usuario\eclipse-workspace\AgriWea\WebContent\js\node_modules\cors\lib\index.js:214:15)
at C:\Users\Usuario\eclipse-workspace\AgriWea\WebContent\js\node_modules\cors\lib\index.js:219:13
at optionsCallback (C:\Users\Usuario\eclipse-workspace\AgriWea\WebContent\js\node_modules\cors\lib\index.js:199:9)
at corsMiddleware (C:\Users\Usuario\eclipse-workspace\AgriWea\WebContent\js\node_modules\cors\lib\index.js:204:7)
at Layer.handle [as handle_request] (C:\Users\Usuario\eclipse-workspace\AgriWea\WebContent\js\node_modules\express\lib\router\layer.js:95:5)
我的NodeJS文件(index.js):


这是我第一次和NodeJS在一起,我有点迷路了。我搜索了“https”,请求是一个函数。。。有什么建议吗?

这是因为您试图调用
rootCas
对象上的函数
request

const https = require('https').globalAgent.options.ca = rootCas;
换句话说,这里您将
rootCas
分配给
require('https').globalAgent.options.ca
https


相反,请尝试以下方法:

const https = require('https');
https.globalAgent.options.ca = rootCas;

这是因为您试图调用
rootCas
对象上的函数
request

const https = require('https').globalAgent.options.ca = rootCas;
换句话说,这里您将
rootCas
分配给
require('https').globalAgent.options.ca
https


相反,请尝试以下方法:

const https = require('https');
https.globalAgent.options.ca = rootCas;