simplehttpcache
v1.0.0
Published
This project will cache http GET and POST requests for a supplied amount of time. It works using Axios
Downloads
11
Readme
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