Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
281 views
in Technique[技术] by (71.8m points)

typescript - JS: ERROR Response with status: 200 for URL: null

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...