Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@fundcount/ts-rx-rest

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

@fundcount/ts-rx-rest

Rest with RxJS and types

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
2
Weekly downloads
 
Created
Source

ts-rx-rest

RxJs Http client for Typescript.

npm version

Provides convenient typed wrappers for http verbs:

  • doGet
  • doPost
  • doPut
  • doDelete

Install

$ npm install --save ts-rx-rest

Usage

import Rest, {errorInterceptor, jsonInterceptor, withCredentialsInterceptors} from 'ts-rx-rest';

const rest = new Rest()
    .wrapRequest(withCredentialsInterceptors) // or .withCredentials()
    .wrap(errorInterceptor) // forwards an XMLHttpRequest object to an error branch of the observable
    .wrap(jsonInterceptor); // converts text representation of the response to json

rest.doGet<Array<User>>('/users').subscribe(users => console.log(users));
Custom interceptors
Request interceptors
const withCredentialsInterceptors = (r: XMLHttpRequest) => {
    r.withCredentials = true;
    return r;
};
Response interceptors
const accessDenied = (observable: Observable<any>) =>
    observable.doOnError(err => {
        if (err.response.status === 403 || err.response.status === 401) {
            // Do some stuff
        }
    });

Keywords

FAQs

Package last updated on 08 Nov 2018

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc