1.0.2 • Published 2 years ago

@fiswat/network v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

@fiswat/network

A simple library to handle network calls.

Installation

Install this package using npm:

npm install @fiswat/network

Usage

Network

The Network class provides a way to call and handle APIs via axios without writing additional error handling logics. Require or import it from the package:

// CommonJS (require)
const { Network } = require('@fiswat/network');

// ECMAScript (import)
import { Network } from '@fiswat/network';

Call an API

To call an API, use Network.call():

// Axios Request config object
const config = {
    method : "get",
    url : "baseurl/endurl",
    params : {
        id: 12
    }
}
const response = await Nework.call(config);
console.log(response);
// {data: {...}, status: 200} or {error: {...}, status: 400} 
1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago