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

@covalent/http

Package Overview
Dependencies
Maintainers
4
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@covalent/http

Teradata UI Platform Http Helper Module

  • 1.0.0-rc.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
171
increased by11.04%
Maintainers
4
Weekly downloads
 
Created
Source

RESTService

Abstract class provided with methods that wraps http services to facilitate REST API calls.

API Summary

Methods
  • query: function(query?: IRestQuery, transform?: IRestTransform)
    • Creates a GET request to the generated endpoint URL.
  • get: function(id: string | number, transform?: IRestTransform)
    • Creates a GET request to the generated endpoint URL, adding the ID at the end.
  • create: function(obj: T, transform?: IRestTransform)
    • Creates a POST request to the generated endpoint URL.
  • update: function(id: string | number, obj: T, transform?: IRestTransform)
    • Creates a PATCH request to the generated endpoint URL, adding the ID at the end.
  • delete: function(id: string | number, transform?: IRestTransform)
    • Creates a DELETE request to the generated endpoint URL, adding the ID at the end.
  • buildUrl: function(id?: string | number, query?: IRestQuery)
    • Builds the endpoint URL with the configured properties and arguments passed in the method.

Usage

Example:

import { Injectable } from '@angular/core';
import { Response, Http, Headers } from '@angular/http';
import { RESTService, HttpInterceptorService } from '@covalent/http';

@Injectable()
export class CustomRESTService extends RESTService<any> {

  constructor(private _http: Http /* or HttpInterceptorService */) {
    super(_http, {
      baseUrl: 'www.api.com',
      path: '/path/to/endpoint',
      headers: new Headers(),
      dynamicHeaders: () => new Headers(),
      transform: (res: Response): any => res.json(),
    });
  }
}

Note: the constructor takes any object that implements the methods in [IHttp] interface. This can be the @angular [Http] service, the covalent [HttpInterceptorService] or a custom service.

export interface IHttp {
  delete: (url: string, options?: RequestOptionsArgs) => Observable<Response>;
  get: (url: string, options?: RequestOptionsArgs) => Observable<Response>;
  head: (url: string, options?: RequestOptionsArgs) => Observable<Response>;
  patch: (url: string, body: any, options?: RequestOptionsArgs) => Observable<Response>;
  post: (url: string, body: any, options?: RequestOptionsArgs) => Observable<Response>;
  put: (url: string, body: any, options?: RequestOptionsArgs) => Observable<Response>;
  request: (url: string | Request, options: RequestOptionsArgs) => Observable<Response>;
}

Keywords

FAQs

Package last updated on 26 Jan 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