easy-http2-angular
Advanced tools
Comparing version 1.0.2 to 1.0.3
{ | ||
"name": "easy-http2-angular", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"peerDependencies": { | ||
@@ -5,0 +5,0 @@ "@angular/common": "^13.3.0", |
@@ -1,24 +0,42 @@ | ||
# EasyHttp | ||
# Easy-Http2-Angular (Angular) | ||
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.3.0. | ||
### Authers: Abdulwahab Herbli - Tasnim Kasab | ||
## Code scaffolding | ||
Run `ng generate component component-name --project easy-http` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project easy-http`. | ||
> Note: Don't forget to add `--project easy-http` or else it will be added to the default project in your `angular.json` file. | ||
## Installation: | ||
## Build | ||
npm i easy-http2-angular@latest | ||
## Basic Usage: | ||
#### Import EasyHttpService in your Service as following: | ||
Run `ng build easy-http` to build the project. The build artifacts will be stored in the `dist/` directory. | ||
import { EasyHttpService } from 'easy-http2-angular'; | ||
## Publishing | ||
#### Here is an example for basic usage: | ||
After building your library with `ng build easy-http`, go to the dist folder `cd dist/easy-http` and run `npm publish`. | ||
async getProducts() { | ||
## Running unit tests | ||
return = await this.httpHelper.get(baseUrl, headers,params); | ||
} | ||
Run `ng test easy-http` to execute the unit tests via [Karma](https://karma-runner.github.io). | ||
## Advance Usage: | ||
#### Import EasyHttpService in your Service as following: | ||
## Further help | ||
import { EasyHttpService } from 'easy-http2-angular'; | ||
#### All the http request functions are genaric type < T > example usage: | ||
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. | ||
async getProducts(): Promise<IProducts[] | String> { | ||
const product: HttpResponseType<IProducts[]> = | ||
await this.httpHelper.get<Promise<IProducts[]> | String>(baseUrl,headers, params); | ||
if (product.status) { | ||
return product.data; | ||
} | ||
return product.msg | ||
} | ||
#### In this case, `HttpResponseType` is: | ||
export interface HttpResponseType<T> { | ||
status?: Boolean; | ||
data?: T; | ||
msg?: String | ||
} |
49051
43