I'm trying to use aws-sdk and aws-cognito-identity-js library with node-red-contrib-function-npm node. I have some questions.
I wrote some code and executed but occurred ReferenceError: fetch is not defined
Do you have any suggestion?
var fetch = require("node-fetch");
global.set("fetch",fetch);
var AWS = require("aws-sdk");
var AmazonCognitoIdentity = require("amazon-cognito-identity-js");
var email = "email";
var passwd = "password";
var poolData={
"UserPoolId": 'userpoolid',
"ClientId": 'clientid'
}
var userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData);
var authData = {
Username : email,
Password : passwd
};
var authDetail = new AmazonCognitoIdentity.AuthenticationDetails(authData);
var cognitoUser = new AmazonCognitoIdentity.CognitoUser(activateInfo);
cognitoUser.authenticateUser(authDetail, {
onSuccess : function(result) {
accessToken = result.getIdToken().getJwtToken();
console.log("idToken:"+accessToken);
},
onFailure : function(err) {
console.log('error: ' + err);
});