I have a basic MongoDB Atlas trigger in NodeJS :
exports = function(changeEvent) {
// Make an http request
};
My goal is to call an AWS lambda function from this trigger, so i would like to know the syntax to make a basic GET
request to a specific endpoint from the NodeJS code.
EDIT :
I am unable to run axios, the dependency is indeed installed but the get
method doesn’t seem to exist.
2
Answers
NPM to install axios in your node js app -> npm i axios
i have put data key in axios to send some data to another server if needed:
First of all, for Lambda functions you will be better off with Event Bridge which is designed exactly for this purpose and utilizes native AWS services directly.
Secondly, you cannot trigger lambda directly without exposing aws console credentials. The better option is to set up an API gateway which accepts http requests and triggers the lambda.
Finally, assuming the API gateway is already there, the Atlas trigger would be as simple as:
UPDATE
Syntax for axios version: