Skip to content

Puspendert/API-Class

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API Class

faster way to generate API calls with axios

Installation

You can install the package using npm

npm install api-class

https://www.npmjs.com/package/api-class

Usage

Create an API instance by import the API class from api-class. As parameter pass the basic url of your api.

const myAPI = new API({ url: '/api' })

Methods

API class exposes the basic CRUD operations

getAll({ query }, config)
getOne({ id }, config)
create(toCreate, config)
update(toUpdate, config)
delete({ id }, config)

Q&A

How to pass headers to axios?

const myAPI = new API({ url: '/api' })
myAPI.getOne({ id: 0 },  { headers: {....} } )

You can check it out my medium article to further informations

https://medium.com/@FrancescoZ/how-to-call-api-in-a-smart-way-2ca572c6fe86

About

A utility class for calling apis CRUD methods

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%