Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>Invoke Lambad in Javascript</title>
- <script src="https://sdk.amazonaws.com/js/aws-sdk-2.92.0.min.js"></script>
- <script type="text/javascript">
- // Configure AWS SDK for JavaScript & set region and credentials
- // global variables to change for this tempalte
- var aws_region = 'us-west-2';
- var identity_pool_id = 'us-west-2:39f57ed5-cbc4-48d3-a174-2f9a2a460f0b';
- var lambda_function_name = 'slotpull';
- // Initialize the Amazon Cognito credentials provider
- AWS.config.region = aws_region; // Region
- AWS.config.credentials = new AWS.CognitoIdentityCredentials({
- IdentityPoolId: identity_pool_id,
- });
- /// Prepare to call Lambda function
- lambda = new AWS.Lambda({region: aws_region, apiVersion: '2015-03-31'});
- var pullParams = {
- FunctionName : lambda_function_name,
- InvocationType : 'RequestResponse',
- LogType : 'None'
- };
- /// CLIENT UI CODE ///
- function init() {
- // Call the Lambda function to collect the results
- lambda.invoke(pullParams, function(err, data) {
- if (err) {
- prompt(err);
- } else {
- pullResults = JSON.parse(data.Payload);
- console.log(pullResults);
- }
- });
- };
- </script>
- </head>
- <body>
- <div>
- <input id="clickMe" type="button" value="click me and check the console" onclick="init();" />
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement