Skip to content

Instantly share code, notes, and snippets.

@ryanstevens
Created October 2, 2015 07:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanstevens/8eb04268fbea267122a8 to your computer and use it in GitHub Desktop.
Save ryanstevens/8eb04268fbea267122a8 to your computer and use it in GitHub Desktop.
var request = require('request');
var cls = require('continuation-local-storage');
var ns = cls.createNamespace('test');
ns.run(function() {
ns.set('foo', 'bar');
setTimeout(function() {
console.log("This is fine " + ns.get('foo'));
}, 0);
request('http://localhost:2382', function(err, resp, body) {
console.log(err);
console.log(ns.get('bar'));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment