New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

angular2-cool-http

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular2-cool-http

Cool features over angular2 Http Client.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
20
decreased by-37.5%
Maintainers
1
Weekly downloads
 
Created
Source

angular2-cool-http

Cool features over angular2 HttpClient

Install

npm install --save angular2-cool-http

Setup

import { bootstrap } from '@angular/platform-browser/browser';
import { COOL_HTTP_PROVIDERS } from 'angular2-cool-http';

import { MyApp } from './src/my-app'

bootstrap(MyApp, [
    COOL_HTTP_PROVIDERS
]);

Features

Api calls

  • getAsync(url, options)
  • postAsync(url, data, options)
  • putAsync(url, data, options)
  • deleteAsync(url, options)
  • patchAsync(url, data, options)
  • headAsync(url, options)
import { Component, OnInit } from '@angular/core';

import { CoolHttp } from 'angular2-cool-http';

@Component({
  selector: 'my-app'
})
export class AppComponent implements OnInit { 
    coolHttp: CoolHttp;
    
    constructor(coolHttp: CoolHttp) {
        this.coolHttp = coolHttp;   
    }
    
    async ngOnInit() {
        let response = await this.coolHttp.getAsync('/api/request');
        
        console.log(response);
    }
}

Global headers

CoolHttp's api calls will always send these globally registered headers. (Great for authentication)

import { CoolHttp, HttpHeader } from 'angular2-cool-http';

coolHttp.registerGlobalHeader(new HttpHeader('MyHttpHeader', 'MyHeadersValue'));

Request Interceptors

CoolHttp's api calls will invoke the registered request interceptors before sending the request

coolHttp.registerRequestInterceptor({
    beforeRequestAsync: function(url, method, data, headers) {
        return new Promise((resolve, reject) => {
            //do something 
            
            resolve();
        });
    }
});

Response Interceptors

CoolHttp's api calls will invoke the registered response interceptors after receiving the response

coolHttp.registerResponseInterceptor({
    afterResponseAsync: function(url, method, data, headers) {
        return new Promise((resolve, reject) => {
            //do something 
            
            resolve();
        });
    }
});

Keywords

FAQs

Package last updated on 29 May 2016

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