【发布时间】:2018-06-25 18:55:26
【问题描述】:
我在使用 SSL 和 CORS 包的 Linux 上设置了 Node.js 服务器。我可以在 Firefox 中使用 HTTPS 协议从 Windows 访问我的网站:
https://<host-name>:<port>/
但是,在我的 Angular 代码中,使用:
http.get("https://<host-name>:<port>/test/data")
我只收到此错误消息*Array.from is not a function*. 在查看开发人员工具屏幕时,我实际上并没有看到浏览器进行 HTTPS 调用。
如果我运行服务器并使用本地浏览器,一切正常!
这可能是 polyfill 问题、另一个 CORS 问题还是其他问题?
这是我的服务的一部分:
...
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable, of } from 'rxjs';
...
export class ObtainData
{
private val: any;
private obsvbl: Observable<any>;
private url = 'https://<host-name>:<port>/test/data';
constructor(private http: HttpClient);
getData(): Observable<any>
{
this.obsvbl = this.http.get<any>(this.url);
this.obsvbl.subscribe((data: any) =>
{
console.log("data is: " + data.val);
// 'val' is a string contained in
// a JSON structure.
this.val = data;
},
err => console.log("Err is: " + err.message),
() => console.log("Done!"));
return this.obsvbl;
}
}
我用这个命令构建:
ng build --aot --base-href=/testing-area/
我无法剪切/粘贴整个堆栈跟踪,但我会在此处尽可能多地输入:
"Err is: Array.from is not a function" (main.js:290)
"ERROR" TypeError: a[getSymbolIterator(...)] is not a function (main.js:393)
stack trace:
areIterablesEqual@https://<host-name>:<port>/testing-area/vendor.js:13061:9
devModeEqual@https://<host-name>:<port>/testing-area/vendor.js:12990:9
{more stuff}
"ERROR CONTEXT" Object(view: Object, nodeIndex: 4, nodeDef: Object, elDef:
Object, elView: Object) (main.js:393)
"ERROR" TypeError: a[getSymbolIterator(...)] is not a function (main.js:393)
stack trace:
{same stuff}
【问题讨论】:
-
请也发布您的服务。
-
如果需要提交更多信息,请让我知道我还可以提供什么。