I have two files, layer-token.js
and server.js
.
layer-token
generates a JWT token, I am using promises using Q to go through the process step by step, everything work fine and the token is generated.
My problem is how to pass the token back to server.js
, currently the value of LayerSessionToken
comes out as [Object Promise]
, how do I access the actual value?
server.js
LayerSessionToken = layerToken.generateToken();
layertoken.js
var returnSessionToken = function(Sessiontoken) {
return Sessiontoken;
}
module.exports = {
generateToken : function()
{
LayerToken= getNonce()
.then(getIdentityToken)
.then(getSession)
.then(returnSessionToken)
.fail(function (error) {
response.write('Computer says no, ' + error.message);
});
return LayerToken
}
}
Your
layertoken.js
returns a PromiseLayerToken
. To get the actual value you call.then
on itMore info on how Promises work