我正在使用下面的代码尝试从响应头中提取值(ReturnStatus);
Keep-Alive: timeout=5, max=100
ReturnStatus: OK,SO304545
Server: Apache/2.4.29 (Win32) OpenSSL/1.0.2m
Run Code Online (Sandbox Code Playgroud)
代码;
import { Injectable } from '@angular/core';
import { Account } from './model/account';
import { HttpClient } from '@angular/common/http';
import { Observable, throwError } from "rxjs";
import { map, filter, catchError, mergeMap } from 'rxjs/operators';
createOrder(url) : Observable<any> {
return this._http.get(url, {withCredentials: true, observe: 'response'})
.pipe(
map((resp: any) => {
console.log("response", resp);
return resp;
}), catchError( error => {
console.log("createOrder error",error );
alert("Create Order Service returned an error. See server …Run Code Online (Sandbox Code Playgroud) 在 Angular 6 中使用最新版本的 rxjs 时遇到问题。
import { Observable, throwError } from "rxjs";
import { map, filter, catchError, mergeMap } from 'rxjs/operators';
isValidUser(user, password) : Observable<any> {
let urlString = "http://localhost....=" + user + "&password=" + password;
console.log(urlString)
return this._http.get(urlString, {withCredentials: true, responseType: 'json'})
.pipe(
map((val: any[]) => {
console.log("val",val);
if (val.hasOwnProperty("GoldUser")) {
if (val["GoldUser"][0]["_Qy"] == "GoldSecurityUser")
this.isUserLoggedIn = true;
return true;
}
return false;
}), catchError( error => {
console.log("error",error );
return throwError( 'Something went wrong!' )
})
); …Run Code Online (Sandbox Code Playgroud)