I have the problem when using https.
I tried this code:
public output(): Observable<Item> {
let headers = new Headers();
headers.append('Content-Type', 'application/x-www-form-urlencoded');
return this.http.get("https://xx.xxx.xx.xx:4433/login", {
headers: headers
})
.pipe(map((response: Response) => {
console.log('response', response)
let res = response.json();
if (res.StatusCode === 1) {
} else {
return new Item('');
}
}));
}
This code show in her part console.log('response', response)
this
JS: ERROR Response with status: 200 for URL: null
Can you ask me any idea?
When change constructor(private http: Http) { }
to constructor(private http: HttpClient) { }
show this error:
JS: ERROR {
JS: "headers": {
JS: "normalizedNames": {},
JS: "lazyUpdate": null,
JS: "headers": {}
JS: },
JS: "status": 0,
JS: "statusText": "Unknown Error",
JS: "url": null,
JS: "ok": false,
JS: "name": "HttpErrorResponse",
JS: "message": "Http failure response for (unknown url): 0 Unknown Error",
JS: "error": {
JS: "originalStack": "Error: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
at new ZoneAwareError (file:///data/data/org.nativescript.smartglass/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:1298:33)
at onRequestComplete (file:///data/data/org.nativescript.smartglass/files/app/tns_modules/tns-core-modules/http/http-request/http-request.js:45:34)
at Object.onComplete (file:///data/data/org.nativescript.smartglass/files/app/tns_modules/tns-core-modules/http/http-request/http-request.js:37:13)",
JS: "zoneAwareStack": "Error: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorE...
Import:
import { Injectable , NgZone } from "@angular/core";
import { Item } from "./item";
import 'rxjs/operators';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { Http, Headers, Response } from '@angular/http';
import { HttpClient} from "@angular/common/http";
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…