ways
ways copied to clipboard
retrieving the current request "state" ?
How can i retrieve the state associated with a request?
For instance:
ways = require( "ways" )
ways( "/save", function( req ) {
console.log( "How to retrieve the state object here?", req );
} );
ways.go( "/save", "", { hi: true } )
Good one, I wonder how it never popped out before. :smile:
Ideally it should be:
ways( "/route", function( req, params, state ) {
// ...
} );
However it should be done, pull requests wellcome.
In this meanwhile, you can do something:
- Here you find the start point for this behavior
- It leads you here or here, depending on what your are using (hash x history).
- Regardless, we found ourselves here at this point, where we can dig the history array:
// pseudo code here (not tested)
var addressbar = require('ways-addressbar');
ways.use(addressbar);
ways( "/route", function( req ) {
console.log(addressbar.history);
} );
ways.go('/route', {hi: true});
Something should be there. :)
i'm not using addressbar.... in that case ?