1.3.12 • Published 6 days ago

base-service-fran-dev v1.3.12

Weekly downloads
-
License
MIT
Repository
github
Last release
6 days ago

base-service

Made with create-react-library

NPM JavaScript Style Guide

Install

npm install --save base-service-fran-dev

Usage

The main purpose is to create a class ob the basic methods for the API requests. Create a service with your BASE_PATH and API endpoint and you will access to the following methods. All methods use Axios request.

-> postData(formdata) -> formdata is the data send to the API. -> postData has the POST method. -> headers : "Content-Type":"application/json" -> Url pass as parameter on the constructor of your class. (endpioint of api)

Create (service).js file

//Methods of BaseService

  async postData(formData){}
  async postDataAuth(formData, logout){}
  async editData(id, formData){}
  async editDataAuth(id, formData, logout){}
  async getAll(page, numberOfItems){}             //page & numberOfItems are optional defaults = ""
  async getAllAuth(logout, page, numberOfItems){} //page & numberOfItems are optional defaults = ""
  async getAllById(id){}          
  async getAllByIdAuth(id, logout){}
  async getById(id){}
  async deleteAuth(id, logout){}
  async delete(id, logout){}
  async filter(irequestFilter){} 
  // let irequestFilter = []
  // irequestFilter.push({'key':'X', 'value': '1'})
  // irequestFilter.push({'key':'y', 'value': '2'})
  // irequestFilter.push({'key':'z', 'value': '3'})
  async uploadDoc(formData, logout)

/////////////////////////////////

//service.js
import { BaseService } from 'base-service-fran-dev'
import { BASE_URL } from '../constants/constants'

export default class Service extends BaseService(){
  constructor(){
    const baseUrl = BASE_URL;
    const endpoint = "endpoint"
    super(baseUrl, endpoint);
  }
}
//////////////////////

//App.js

import Service from './service.js' //import service

async function functionName(){
    let Service = new Service();
    let response = await Service.postData({data})
}
logout()

License

MIT © fran-dev

1.3.11

6 days ago

1.3.12

6 days ago

1.3.10

3 months ago

1.3.9

3 months ago

1.3.8

1 year ago

1.3.6

1 year ago

1.3.5

1 year ago

1.3.4

1 year ago

1.3.3

1 year ago

1.2.8

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.9

2 years ago

1.2.7

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.0

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.2.1

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago