Friday 19 May 2017

Sub callback in NodeJS for AWS Lambda

How can my AWS Lambda make an API call to some external service and return the output to the user who invoked the function please?

My piece of code looks like this:

module.exports.oauth_callback = (event, context, callback) => {
  oauth2.authorizationCode.getToken({
    redirect_uri: 'https://' + event.headers.Host + event.requestContext.path
    }).then(results => {
      callback(null, {statusCode: 200, body: JSON.stringify(results)});
  });
};

With this, I receive a 500 Internal Error because I believe the lambda function is exiting before returning the result.



via Arkon

No comments:

Post a Comment