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

fluxible-plugin-fetchr

Package Overview
Dependencies
Maintainers
5
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fluxible-plugin-fetchr - npm Package Compare versions

Comparing version 0.1.2 to 0.2.0

.idea/.name

11

lib/fetchr-plugin.js

@@ -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 @@ ```

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