Skip to content

sergei-vasilenko/quickapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quick api

Description

Function for quick creation and convenient use of network requests.

Note

Wrapper over the fetch.

Arguments

When you first call the function, you can pass three parameters: host, ?globalOptions and ?credentials.

Then you can configure the application in a chain:

  • plugin <Object> - expand the functionality of the application.
  • module: <Object> - to add a module. Modules are designed to group methods of working with the server.
  • interseptor: type <String> handler <Function> - request processing. type [ requestbefore | requesterror | responsebefore | responseerror ].
  • separator: <String> - separator character.

Don't forget to call the function without arguments () or specify a mode to initialize it.

Usage Examples:

const host = "https://jsonplaceholder.typicode.com/";
const globalOptions = null;
const credentials = "include";

const prepareApi = quickApi(host, globalOptions, credentials);
const api = prepareApi
  .plugin(onlyLastExt)
  .plugin(relaunchExt)
  .module(postsModule)("dev");

(async () => {
  const result = await api("posts.list", { limit: 20 });
  console.log("RESULT", result);
})();

About

Quick to set up, easy to use, simple to expand.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published