Search code examples
javascriptnode.jsamazon-web-servicesamazon-rekognition

TypeError: AWS.rekognition is not a constructor


const AWS  = require('aws-sdk')

AWS.config.loadFromPath('./credentials.json');
AWS.config.update({region:'us-east-1'});


var rekognition = new AWS.rekognition();

var params = {
    CollectionId: "sammple", 
    DetectionAttributes: [  
    ], 
    ExternalImageId: "facialrekogntition",  //TODo
    Image: {
     S3Object: {
      Bucket: "facerekognition12", 
      Name: "download.jpg"
     }
    }
   };
   rekognition.indexFaces(params, function(err, data) {
     if (err) console.log(err, err.stack); // an error occurred
     else     console.log(data);           // successful response
   });

Whenever I use node index.js, I am getting the error mentioned in the title.

Note - I have my credentials stored in the JSON file and also installed AWS-SDK for node.


Solution

  • It's new AWS.Rekognition(); basically capital R