Javascript 点头。TypeError:https.request不是函数
我正在用AngularJS编写一个web应用程序,由于CORS问题,我使用NodeJS。嗯,当我试图在我的节点中发出请求时,会出现以下错误: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
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;