simple-api-request
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

ApiRequest

The module to work with API

Quick installation

From your project app run below :

npm i --save api-request/dist/api-request-<version>.tgz

Add the module to the project app module e.g app.module.ts :

import { ApiRequestModule } from 'api-request';
...

imports: [
    ...
    ApiRequestModule
]

Finally, insert the element to the component template e.g :

<api-request #api (apiEvent)="listener($event)" [baseUrl]="baseUrl"></api-request>

To make a request :

Format:
this.api.service.call("post" || "get", endpoint<string>, body<any>, header<any>)

e.g
this.api.service.call("post", "/api/auth/", 
    {
        username: "user1", 
        password: "123456"
    },
    {
        'Content-Type': 'application/json',
        'Accept': 'application/json'
    }).subscribe(
        result => console.log(result),
        error => console.log(error)
    )

Package Sidebar

Install

npm i simple-api-request

Weekly Downloads

1

Version

1.0.2

License

none

Unpacked Size

114 kB

Total Files

28

Last publish

Collaborators

  • mahdiiridho