New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@dewib/xhr-cache

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dewib/xhr-cache - npm Package Compare versions

Comparing version 1.0.0 to 1.0.2

.history/library_20191214184601.js

39

library.js

@@ -35,4 +35,31 @@ import { dirname } from 'path'

return axios(config).catch((err) => {
return { data: request.catch } || Promise.reject(err)
return axios(config).then((response) => {
if (!response.data) {
const error = `${libPrefix} Response from ${request.url} is empty`
if (typeof request.catch !== 'undefined') {
error += ` using provided default value ${request.catch}`
/* eslint-disable-next-line */
console.error(error)
return { data: request.catch }
}
// Returning default value to avoid null value
/* eslint-disable-next-line */
console.error(`${error} using default value {}`)
return { data: {} }
}
return response
}).catch((err) => {
if (typeof request.catch !== 'undefined') {
/* eslint-disable-next-line */
console.error(`${libPrefix} Error on fetching resource ${request.url} returning catch value: ${err}`)
return { data: request.catch }
}
return Promise.reject(err)
})

@@ -45,3 +72,9 @@ }

return JSON.parse(fs.readFileSync(path, 'UTF-8'))
try {
return JSON.parse(fs.readFileSync(path, 'UTF-8'))
} catch (err) {
console.err(`${libPrefix} Unable to parse JSON from ${path}`)
return {}
}
}

@@ -48,0 +81,0 @@

2

package.json
{
"name": "@dewib/xhr-cache",
"version": "1.0.0",
"version": "1.0.2",
"license": "MIT",

@@ -5,0 +5,0 @@ "description": "Cache api resources and serve it as static resource",

@@ -1,2 +0,2 @@

# XHR Cache Module
# XHR Cache Module v1.0.2

@@ -20,3 +20,3 @@ > Cache application/json api resources and serve it as static resource

[
'xhr-cache'
'@dewib/xhr-cache'
]

@@ -45,3 +45,4 @@ ]

url: 'http://www.mocky.io/v2/5d9e4c643200002a00329d0a'
}
},
catch: [] // Value used if request failed or response is empty
}

@@ -55,6 +56,8 @@ ]

XHR cache expose routes to refresh a resource manually.
XHR cache expose routes to refresh a resource manually
All routes are exposed during nuxtjs start with the specific path:
All routes are exposed once the first called has been made to the resource or if the init resource option is set to true
The refresh route is generated like this:
```javascript

@@ -64,3 +67,3 @@ path.join(

'/cache/refresh/',
id // Generated id of resource
id) // Generated id of resource
```

@@ -67,0 +70,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc