simplehttpcache

1.0.0 • Public • Published

Simple Http Cache

This project will cache http GET and POST requests for a supplied amount of time. It works using Axios

Demo

Insert gif or link to demo

Example Usage

Import the project using npm i SimpleHttpCache

var SimpleHttpCache = require("SimpleHttpCache");

Get Request

setInterval(async ()=>{
    var sample = await SimpleHttpCache.get("https://reqbin.com/echo/get/json", 5000) // cache for 5 seconds
    console.log(sample) // will return data.__cached = false once, then true after 5 requests
} , 1000)

Post Request


setInterval(async ()=>{
    var sample = await SimpleHttpCache.post("https://reqbin.com/sample/post/json",{ key: "value"}, 5000) // cache for 5 seconds
    console.log(sample) // will return data.__cached = false once, then true after 5 requests
} , 1000)

Very simple implementation, use at you own risk

By Ryan Trattner for ITSMRSHEEEN

Readme

Keywords

none

Package Sidebar

Install

npm i simplehttpcache

Weekly Downloads

3

Version

1.0.0

License

ISC

Unpacked Size

3.03 kB

Total Files

5

Last publish

Collaborators

  • rtiscool