** Here is the code for cognito-user and I have to use the token value in another file, so how can I use, how can I export token value?**
const {
AuthenticationDetails,
CognitoUser,
CognitoUserPool
} = require("amazon-cognito-identity-js");
var poolData = {
UserPoolId : '', // your user pool id here
ClientId : '' // your client id here
};
var userPool = new CognitoUserPool(poolData);
var userData = {
Username : '', // your username here
Pool : userPool
};
var cognitoUser = new CognitoUser(userData);
var authenticationData = {
Username: '',
Password: '',
};
var authenticationDetails = new AuthenticationDetails(authenticationData);
cognitoUser.authenticateUser(authenticationDetails, {
onSuccess:function(data) {
var token = data.getIdToken().getJwtToken()
console.log("user",token)
}
})