Adarsh-kushwaha / carrierjs

Carrier JS is promise based http client for browsers. It is used to interact with servers with ultimate caching feature.

Home Page:https://theritikchoure.github.io/carrierjs/doc/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Carrier JS

Carrier JS is promise based http client for browsers. It is used to interact with servers with ultimate caching feature. You can retrieve data from a URL without having to do a full page refresh. This enables a Web page to update just part of a page without disrupting what the user is doing.

NPM JavaScript Style Guide install size

NPM

Install

Using NPM

npm install --save carrierjs

Using CDN

<script src="https://theritikchoure.github.io/carrierjs/carrier.js">

Using jsDelivr

<script src="https://cdn.jsdelivr.net/npm/carrierjs@1/carrier.min.js">

Using unpkg

<script src="https://unpkg.com/carrierjs@1.0.1/carrier.js">

Features of CarrierJs

  • Make XMLHttpRequest from browser
  • Supports All Browsers
  • Enable IndexedDB Based Caching which can store 250MB of data
  • Data will not expire unless explicit deletion of the database (persistent storage)

Usage

Performing a GET request:

// Using Promise
carrier.get('https://jsonplaceholder.typicode.com/todos/').then((result) => {
    console.log(result)
}).catch((err) => {
    console.log(err)
});

---------

// Using Async/Await
async function getUser() {
  try {
    const response = await carrier.get('https://jsonplaceholder.typicode.com/todos/')
    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

Performing a POST request:

const data = {
	title: "delectus aut autem",
	completed: false
}

// Using Promise
carrier.post('/todos', data).then((result) => {
    console.log(result)
}).catch((err) => {
    console.log(err)
});

---------

// Using Async/Await
async function createUser(data) {
  try {
    const response = await carrier.post('/todos', data)
    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

createUser(data);

Performing a PUT request:

const data = {
	title: "delectus aut autem",
	completed: false
}

// Using Promise
carrier.put('/todos', data).then((result) => {
    console.log(result)
}).catch((err) => {
    console.log(err)
});

---------

// Using Async/Await
async function createUser(data) {
  try {
    const response = await carrier.put('/todos', data)
    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

createUser(data);

Supports

This library supports on every browsers.

Fast & Light

It is a simple, fast and lightweight javascript library.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

License

This package is licensed under the MIT license © theritikchoure

About

Carrier JS is promise based http client for browsers. It is used to interact with servers with ultimate caching feature.

https://theritikchoure.github.io/carrierjs/doc/

License:MIT License


Languages

Language:JavaScript 74.9%Language:HTML 25.1%