Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

storyblok-js-client

Package Overview
Dependencies
Maintainers
1
Versions
197
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

storyblok-js-client - npm Package Compare versions

Comparing version 1.0.7 to 1.0.8

test.ts

10

dist/index.js

@@ -11,2 +11,3 @@ 'use strict';

var hash = require('object-hash');
var qs = require('qs');
var axios = require('axios');

@@ -75,3 +76,3 @@ var throttledQueue = require('throttled-queue');

return new Promise(function (resolve, reject) {
var cacheKey = hash({ url: url, params: params });
var cacheKey = qs.stringify({ url: url, params: params }, { arrayFormat: 'brackets' });
var provider = _this.cacheProvider();

@@ -88,3 +89,8 @@ var cache = provider.get(cacheKey);

_this.throttle(function () {
_this.client.get(url, { params: params }).then(function (res) {
_this.client.get(url, {
params: params,
paramsSerializer: function paramsSerializer(params) {
return qs.stringify(params, { arrayFormat: 'brackets' });
}
}).then(function (res) {
var response = { data: res.data, headers: res.headers };

@@ -91,0 +97,0 @@

{
"name": "storyblok-js-client",
"version": "1.0.7",
"version": "1.0.8",
"description": "Universal JavaScript SDK for Storyblok's API",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {

@@ -29,5 +30,5 @@ "build": "babel source --presets babel-preset-es2015 --plugins transform-object-assign --out-dir dist"

"axios": "^0.17.1",
"object-hash": "^1.1.8",
"qs": "^6.5.2",
"throttled-queue": "^1.0.5"
}
}

48

README.md

@@ -86,8 +86,52 @@ # Universal JavaScript SDK for Storyblok's API

### Nodejs code example
### Code examples
#### Filter by content type values and path
~~~javascript
const StoryblokClient = require('storyblok-js-client')
let client = new StoryblokClient({
accessToken: 'zlRONoLBKrilxkz2k6fYuwtt'
})
// Filter by boolean value in content type
client.get('cdn/stories', {
version: 'draft',
filter_query: {
is_featured: {
all: '1'
}
}
}).then((res) => {
console.log(res.data.stories)
})
// Get all news and author contents
client.get('cdn/stories', {
version: 'draft',
filter_query: {
component: {
in: 'news,author'
}
}
}).then((res) => {
console.log(res.data.stories)
})
// Get all content from the news folder
client.get('cdn/stories', {
version: 'draft',
starts_with: 'news/'
}).then((res) => {
console.log(res.data.stories)
})
~~~
#### Download all content from Storyblok
Following a code example using the storyblok-js-client to backup all content on your local filesystem inside a 'backup' folder.
~~~javascript
let StoryblokClient = require('./dist/index.js')
const StoryblokClient = require('storyblok-js-client')
const fs = require('fs')

@@ -94,0 +138,0 @@

@@ -5,2 +5,3 @@ 'use strict'

const hash = require('object-hash')
const qs = require('qs')
const axios = require('axios')

@@ -61,3 +62,3 @@ const throttledQueue = require('throttled-queue')

return new Promise((resolve, reject) => {
let cacheKey = hash({url: url, params: params})
let cacheKey = qs.stringify({url: url, params: params}, {arrayFormat: 'brackets'})
let provider = this.cacheProvider()

@@ -74,3 +75,6 @@ let cache = provider.get(cacheKey)

this.throttle(() => {
this.client.get(url, {params: params})
this.client.get(url, {
params: params,
paramsSerializer: params => qs.stringify(params, {arrayFormat: 'brackets'})
})
.then((res) => {

@@ -77,0 +81,0 @@ let response = {data: res.data, headers: res.headers}

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