storyblok-js-client
Advanced tools
Comparing version 1.0.7 to 1.0.8
@@ -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" | ||
} | ||
} |
@@ -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} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14939
5
336
176
+ Addedqs@^6.5.2
+ Addedcall-bind@1.0.7(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedqs@6.13.1(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedside-channel@1.0.6(transitive)
- Removedobject-hash@^1.1.8
- Removedobject-hash@1.3.1(transitive)