1.0.2 • Published 1 year ago

@feedma/http-service v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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();
};
1.0.2

1 year ago

1.0.1

2 years ago

1.0.0

2 years ago

1.0.0-beta.1

2 years ago

1.0.0-alpha.3

2 years ago

1.0.0-alpha.2

2 years ago