{"id":13661182,"url":"https://github.com/Hacklone/angular2-cool-http","last_synced_at":"2025-04-24T23:31:58.918Z","repository":{"id":57179561,"uuid":"59928676","full_name":"Hacklone/angular2-cool-http","owner":"Hacklone","description":"Cool features over angular2 HttpClient","archived":false,"fork":false,"pushed_at":"2018-05-11T08:41:23.000Z","size":1908,"stargazers_count":36,"open_issues_count":0,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-12T15:06:37.225Z","etag":null,"topics":["angular","angular-cool","angular2-cool","angular2-httpclient","cookie","http","request-interceptors","responseinterceptor"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Hacklone.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-29T05:55:38.000Z","updated_at":"2023-08-21T14:15:04.000Z","dependencies_parsed_at":"2022-09-14T02:10:16.086Z","dependency_job_id":null,"html_url":"https://github.com/Hacklone/angular2-cool-http","commit_stats":null,"previous_names":[],"tags_count":62,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hacklone%2Fangular2-cool-http","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hacklone%2Fangular2-cool-http/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hacklone%2Fangular2-cool-http/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hacklone%2Fangular2-cool-http/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hacklone","download_url":"https://codeload.github.com/Hacklone/angular2-cool-http/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250727719,"owners_count":21477359,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","angular-cool","angular2-cool","angular2-httpclient","cookie","http","request-interceptors","responseinterceptor"],"created_at":"2024-08-02T05:01:30.744Z","updated_at":"2025-04-24T23:31:53.903Z","avatar_url":"https://github.com/Hacklone.png","language":"TypeScript","readme":"[npm-url]: https://npmjs.org/package/angular2-cool-http\n[npm-image]: https://img.shields.io/npm/v/angular2-cool-http.svg\n[downloads-image]: https://img.shields.io/npm/dm/angular2-cool-http.svg\n[total-downloads-image]: https://img.shields.io/npm/dt/angular2-cool-http.svg\n\n# !!!!!!\n# This version of angular2-cool-http is deprecated and only left here for reference.\n# Please use [@angular-cool/http](https://www.npmjs.com/package/@angular-cool/http) instead!\n# !!!!!!\n\n# angular2-cool-http [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url]  [![Total Downloads][total-downloads-image]][npm-url]\nCool features over angular2 HttpClient\n\n## Install \n\u003e npm install --save angular2-cool-http\n\n## Setup\n```javascript\nimport { NgModule } from '@angular/core';\nimport { CoolHttpModule } from 'angular2-cool-http';\n\n@NgModule({\n    imports: [CoolHttpModule]\n})\nexport class MyAppModule {}\n```\n\n## Features\n### Global base url\nCoolHttp's api calls will always prefix your url with the baseUrl set (Great for cross origin websites)\n\n```javascript\ncoolHttp.registerBaseUrl('https://my.api.com/');\n```\n\n```javascript\ncoolHttp.deRegisterBaseUrl();\n```\n\n### Global withCredentials\nCoolHttp's api calls will always send cookies to cross domain requests (Great for cross origin websites)\n\n```javascript\ncoolHttp.setWithCredentials(true);\n```\n\n### Async Api calls\n- getAsync\u003cT\u003e(url: string, options: RequestOptions): Promise\u003cT\u003e\n- postAsync\u003cT\u003e(url: string, data: any, options: RequestOptions): Promise\u003cT\u003e\n- putAsync\u003cT\u003e(url: string, data: any, options: RequestOptions): Promise\u003cT\u003e\n- deleteAsync\u003cT\u003e(url: string, options: RequestOptions): Promise\u003cT\u003e\n- patchAsync\u003cT\u003e(url: string, data: any, options: RequestOptions): Promise\u003cT\u003e\n- headAsync\u003cT\u003e(url: string, options: RequestOptions): Promise\u003cT\u003e\n\n```javascript\nimport { Component, OnInit } from '@angular/core';\n\nimport { CoolHttp } from 'angular2-cool-http';\n\n@Component({\n  selector: 'my-app'\n})\nexport class AppComponent implements OnInit { \n    coolHttp: CoolHttp;\n    \n    constructor(coolHttp: CoolHttp) {\n        this.coolHttp = coolHttp;   \n    }\n    \n    async ngOnInit() {\n        // await async api call\n        let response = await this.coolHttp.getAsync('/api/request');\n        \n        console.log(response);\n        \n        // or simply chain Promise\n        this.coolHttp.getAsync('/api/request')\n            .then(response =\u003e {\n                console.log(response);\n            });\n    }\n}\n```\n\n### Observable api calls\n- getObservable\u003cT\u003e(url: string, options: RequestOptions): Observable\u003cT\u003e\n- postObservable\u003cT\u003e(url: string, data: any, options: RequestOptions): Observable\u003cT\u003e\n- putObservable\u003cT\u003e(url: string, data: any, options: RequestOptions): Observable\u003cT\u003e\n- deleteObservable\u003cT\u003e(url: string, options: RequestOptions): Observable\u003cT\u003e\n- patchObservable\u003cT\u003e(url: string, data: any, options: RequestOptions): Observable\u003cT\u003e\n- headObservable\u003cT\u003e(url: string, options: RequestOptions): Observable\u003cT\u003e\n\n### Global headers\nCoolHttp's api calls will always send these globally registered headers. (Great for authentication)\n\n```javascript\nimport { CoolHttp, HttpHeader } from 'angular2-cool-http';\n\ncoolHttp.registerGlobalHeader(new HttpHeader('MyHttpHeader', 'MyHeadersValue'));\n```\n\n- registerGlobalHeader(header: HttpHeader): void\n- deregisterGlobalHeader(headerKey: string): boolean\n- removeAllRegisteredGlobalHeaders(): void\n\n### Request Interceptors\nCoolHttp's api calls will invoke the registered request interceptors before sending the request\n\n- registerRequestInterceptor(requestInterceptor: IRequestInterceptor): void\n- deregisterRequestInterceptor(requestInterceptor: IRequestInterceptor): boolean\n\n```javascript\ncoolHttp.registerRequestInterceptor({\n    beforeRequestAsync: function(url, method, data, headers) {\n        return new Promise((resolve, reject) =\u003e {\n            // do something \n            \n            // resolve with true to fully intercept request\n            // resolve with false to let the request continue\n            resolve(false);\n        });\n    }\n});\n```\n\n### Response Interceptors\nCoolHttp's api calls will invoke the registered response interceptors after receiving the response\n\n- registerResponseInterceptor(responseInterceptor: IResponseInterceptor): void\n- deregisterResponseInterceptor(responseInterceptor: IResponseInterceptor): boolean\n\n```javascript\ncoolHttp.registerResponseInterceptor({\n    afterResponseAsync: function(url, method, data, headers) {\n        return new Promise((resolve, reject) =\u003e {\n            //do something \n            \n            // resolve with true to fully intercept the response handling\n            // resolve with false to let the response handling continue\n            resolve(true);\n        });\n    }\n});\n```\n\n## Automatic cookie to custom header sending\nYou can configure CoolHttp to copy and send a cookie value in a custom http header.\n\n```javascript\ncoolHttp.sendCookieValueInCustomHeader(cookieName, headerName);\n```\n\n## License\n\u003e The MIT License (MIT)\n\n\u003e Copyright (c) 2016 Hacklone\n\u003e https://github.com/Hacklone\n\n\u003e Permission is hereby granted, free of charge, to any person obtaining a copy\n\u003e of this software and associated documentation files (the \"Software\"), to deal\n\u003e in the Software without restriction, including without limitation the rights\n\u003e to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n\u003e copies of the Software, and to permit persons to whom the Software is\n\u003e furnished to do so, subject to the following conditions:\n\n\u003e The above copyright notice and this permission notice shall be included in all\n\u003e copies or substantial portions of the Software.\n\n\u003e THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\u003e IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\u003e FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\u003e AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\u003e LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\u003e OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n\u003e SOFTWARE.\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHacklone%2Fangular2-cool-http","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FHacklone%2Fangular2-cool-http","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHacklone%2Fangular2-cool-http/lists"}