1.3.15 • Published 5 months ago

base-service-fran-dev v1.3.15

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months 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.15

5 months ago

1.3.13

5 months ago

1.3.14

5 months ago

1.3.11

1 year ago

1.3.12

1 year ago

1.3.10

1 year ago

1.3.9

1 year ago

1.3.8

2 years ago

1.3.6

2 years ago

1.3.5

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.2.8

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.9

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.0

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.2.1

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago