New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

fetch-json-cache

Package Overview
Dependencies
Maintainers
1
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-json-cache

Caches fetched json. Updates when etag changes and is uses cache regardless if endpoint unreachable. Uses write-file-atomic for safe updates

latest
Source
npmnpm
Version
1.6.1
Version published
Maintainers
1
Created
Source

fetch-json-cache

Caches fetched json. Updates when etag changes and is uses cache regardless if endpoint unreachable. Uses write-file-atomic for safe updates.

var Cache = require('fetch-json-cache');
var assert = require('assert');

var cache = new Cache('/path/to/cache');

//////////////
// callbacks
//////////////

// get
cache.get('https://jsonplaceholder.typicode.com/users', function(err, json) {
  assert.ok(json.length > 0);
})

// get with forced update
cache.get('https://jsonplaceholder.typicode.com/users', { force: true }, function(err, json) {
  assert.ok(json.length > 0);
})

// clear the cache
cache.clear(function(err) {
})

//////////////
// promise
//////////////

// get
var json = await cache.get('https://jsonplaceholder.typicode.com/users')
assert.ok(json.length > 0);

// get with forced update
var json2 = await cache.get('https://jsonplaceholder.typicode.com/users', { force: true })
assert.ok(json2.length > 0);

// clear the cache
await cache.clear()

Keywords

every

FAQs

Package last updated on 27 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts