fluxible-plugin-fetchr
Advanced tools
Comparing version 0.1.2 to 0.2.0
@@ -9,3 +9,2 @@ /** | ||
var Fetchr = require('fetchr'); | ||
var objectAssign = require('object-assign'); | ||
@@ -67,7 +66,9 @@ /** | ||
* @param {Object} contextOptions.req The server request object (only supplied if on server) | ||
* @param {Object} contextOptions.dimensions Request context dimensions (e.g. { device: "tablet" }) | ||
* @param {Object} contextOptions.xhrContext Context object that will be used for all | ||
* XHR calls from the client. This allows persistence of some values between requests | ||
* and also CSRF validation. (e.g. { _csrf: 'a3fc2f', device: "tablet" }) | ||
* @returns {Object} | ||
*/ | ||
plugContext: function plugContext(contextOptions) { | ||
var dimensions = contextOptions.dimensions; | ||
var xhrContext = contextOptions.xhrContext; | ||
return { | ||
@@ -83,3 +84,3 @@ /** | ||
xhrPath: xhrPath, | ||
context: objectAssign({}, dimensions) | ||
context: xhrContext | ||
}); | ||
@@ -112,3 +113,3 @@ actionContext.service = { | ||
rehydrate: function rehydrate(state) { | ||
dimensions = state.dimensions; | ||
xhrContext = state.xhrContext; | ||
} | ||
@@ -115,0 +116,0 @@ }; |
{ | ||
"name": "fluxible-plugin-fetchr", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"description": "A plugin for fluxible applications to provide an isomorphic interface for RESTful services", | ||
@@ -13,4 +13,3 @@ "main": "index.js", | ||
"debug": "^2.0.0", | ||
"fetchr": "^0.4.0", | ||
"object-assign": "^2.0.0" | ||
"fetchr": "^0.4.0" | ||
}, | ||
@@ -17,0 +16,0 @@ "devDependencies": { |
@@ -23,7 +23,11 @@ # Fetchr Plugin for Fluxible App | ||
Now, when calling the `createContext` method on the server, make sure to send in the request object: | ||
Now, when calling the `createContext` method on the server, make sure to send in the request object and optionally pass an `xhrContext` which will be used as parameters for all XHR calls: | ||
``` | ||
app.createContext({ | ||
req: req | ||
req: req, | ||
xhrContext: { // Used as query params for all XHR calls | ||
lang: 'en-US', // make sure XHR calls receive the same lang as the initial request | ||
_csrf: 'a3fc2d' // CSRF token to validate on the server using your favorite library | ||
} | ||
}); | ||
@@ -30,0 +34,0 @@ ``` |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
36668
2
21
155
87
0
- Removedobject-assign@^2.0.0
- Removedobject-assign@2.1.1(transitive)