Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@covalent/http-deprec

Package Overview
Dependencies
Maintainers
4
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@covalent/http-deprec

Teradata UI Platform Http Helper Module (deprecated)

latest
Source
npmnpm
Version
2.1.1
Version published
Maintainers
4
Created
Source

RESTService (deprecated)

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

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-deprec';

@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

angular

FAQs

Package last updated on 20 Aug 2019

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