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

1.1.1 • Public • Published

@wiseidea/util-service

Service Utility

Features

  • Get all data from service
  • Get data by id from service
  • Add new data
  • Update data by id
  • Partial update data by id
  • Delete data by id

Installing

Using npm:

$ npm install @wiseidea/util-service

Using yarn:

$ yarn add @wiseidea/util-service

Example

// Import Service
import Service, { ServiceResponse } from "@wiseidea/util-service";

// Create object
const service: Service = new Service("http://www.example.com/api");

Get all data from service

const resp: ServiceResponse = await service.getAll();

Get data by id from service

const resp: ServiceResponse = await service.getById(id);

Add new data

const resp: ServiceResponse = await service.create(data);

Update data by id

const resp: ServiceResponse = await service.update(id, data);

Partial update data by id

const resp: ServiceResponse = await service.partialUpdate(id, data);

Delete data by id

const resp: ServiceResponse = await service.delete(id);

Custom get data by subUrl

const resp: ServiceResponse = await service.httpGet(subUrl);

Custom post data by subUrl

const resp: ServiceResponse = await service.httpPost(subUrl, data);

Custom put data by subUrl

const resp: ServiceResponse = await service.httpPut(subUrl, data);

Custom patch data by subUrl

const resp: ServiceResponse = await service.httpPatch(subUrl, data);

Custom delete data by subUrl

const resp: ServiceResponse = await service.httpDelete(subUrl);

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @wiseidea/util-service

Weekly Downloads

0

Version

1.1.1

License

MIT

Unpacked Size

14 kB

Total Files

9

Last publish

Collaborators