小编Mar*_*non的帖子

Angular 6使用httpclient问题获取响应标头

我正在使用下面的代码尝试从响应头中提取值(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 angular-httpclient

9
推荐指数
1
解决办法
3万
查看次数

Angular 6 rxjs 管道不返回数据

在 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)

rxjs angular

2
推荐指数
1
解决办法
2250
查看次数

标签 统计

angular ×2

angular-httpclient ×1

rxjs ×1