@feedma/http-service
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

semantic-release: angular npm version

Quickstart

Installation

See the full documentation

NPM

npm i axios @feedma/http-service

YARN

yarn add axios @feedma/http-service

Create a service

Typescript

// JsonPlaceHolderService.ts

import { HttpService } from '@feedma/http-service';
import { AxiosRequestConfig } from 'axios';

export class JsonPlaceHolderService extends HttpService {
  protected config: AxiosRequestConfig = { 
    baseURL: "https://jsonplaceholder.typicode.com" ,
  };
  
  async fetchUsers(): Promise<AxiosResponse> {
    return this.client.get('/users');
  }
  // Yor request methods here ...
}

Javascript

// JsonPlaceHolderService.js

import { HttpService } from '@feedma/http-service';

export class JsonPlaceHolderService extends HttpService {
  
  constructor(requestInterceptors = [], responseInterceptors = []) {
    super(requestInterceptors, responseInterceptors);
    this.config = {
      baseURL: "https://jsonplaceholder.typicode.com",
    };
  }
  
  async fetchUsers() {
    return this.client.get('/users');
  }
  // Yor request methods here ...
}

Make request

Typescript

// app.ts

import { JsonPlaceHolderService } from './JsonPlaceHolderService';

const service: JsonPlaceHolderService = new JsonPlaceHolderService();

const app = async () => {
  const { data } = await service.fetchUsers();
};

Javascript

// app.js

import { JsonPlaceHolderService } from './JsonPlaceHolderService';

const service = new JsonPlaceHolderService();

const app = async () => {
  const { data } = await service.fetchUsers();
};

Package Sidebar

Install

npm i @feedma/http-service

Weekly Downloads

4

Version

1.0.2

License

MIT

Unpacked Size

101 kB

Total Files

20

Last publish

Collaborators

  • feedma