Access-Control-Allow-Origin' header

hi
I keep getting this error when I try to call api using javascript

functions:
  hello:
    handler: handler.hello
    memorySize: 512
    events:
      - http: 
          path : greete
          method : get
          cors : true

and calling from Javascript

    AWS.config.credentials.get( (err) => {
      if (!err) {

           var apigClient = apigClientFactory.newClient({
            accessKey: AWS.config.credentials.accessKeyId,
            secretKey: AWS.config.credentials.secretAccessKey,
            sessionToken: AWS.config.credentials.sessionToken,
            region: 'us-east-1' 
            });
            
          apigClient.greeteGet({}, body)
            .then(function(result){
                //This is where you would put a success callback
                console.log(result)
            }).catch( function(result){
                //This is where you would put an error callback
            })
        }      
    });

any idea how to authorize with cognito and pass the identity to lambda function.

1 Like