New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@cmss/http-client-rxjs

Package Overview
Dependencies
Maintainers
2
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cmss/http-client-rxjs

httpModule是由Angular的httpClient模块打包的网络请求库。Angular的httpClient模块采用了typescript和Rx.js。使用httpModule要用函数式的方式,如果用上Rx.js丰富的操作符,可以写出十分简洁明了的代码。 ## 基本用法 ```js // http配置 const httpOptions = { headers: { 'Content-Type': 'application/json' } };

latest
npmnpm
Version
1.0.0
Version published
Maintainers
2
Created
Source

httpModule

httpModule是由Angular的httpClient模块打包的网络请求库。Angular的httpClient模块采用了typescript和Rx.js。使用httpModule要用函数式的方式,如果用上Rx.js丰富的操作符,可以写出十分简洁明了的代码。

基本用法

// http配置
const httpOptions = {
  headers: {
    'Content-Type': 'application/json'
  }
};

let http = new RestClient(httpOptions);

// 发起请求
http.get(url).subscribe(value => {
  ...
})

错误处理

import { throwError } from 'rxjs';
import { retry, catchError } from 'rxjs/operators';

const handleError = (error) => {
  ...
  // 返回一个 observable 用于 rxjs catch 处理,方便用户自定义 catch 处理方式。
  return throwError('Something bad happened; please try again later.');
}

http.get(url).pipe(
  retry(3),
  catchError(handleError)
).subscribe(value => {
  ...
})

FAQs

Package last updated on 27 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts