This is the code used the article Automated SMS notifications with AWS Lambda and Twilio APIs published on Twilio's blog
Here follows a detailed description of every part of the code:
- The first thing we do is to import the
request-promise-nativelibrary. - Then we declare our handler function by respecting the expected signature with
event,contextandcallbackas described previously. - Inside the handler, we define some constants that we will use as configuration in the rest of the code. Be sure to fill in all the values that are specific to your account.
- At this point we are ready to perform the first API request to get the exchange rate from Fixer.io.
- Since
request-promise-nativereturns a promise, we have to write a then and acatchmethod to handle the asynchronous control flow. Inside the then we have get the response data from the API call and we can use it to extract the current exchange rate. We also log the result, which is a go