I’m trying to call an AWS Lambda function using Javascript in a PHP field in a View. Currently, a bit of my code looks like this:
<!DOCTYPE html> <html> <script src="https://sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js"> </script> <button id="download-button">Download</button> <script type="text/javascript"> var bucketName = 'test-bucket'; var bucket = new AWS.S3({ params: { Bucket: bucketName } }); // function defined below, etc </script> </html>
However, I’m getting an error on the page that says “Uncaught ReferenceError: AWS is not defined”.
When I run this code on my own computer though, I don’t receive that error, however. It’s just with Drupal.
I’m not given many permissions to edit the filesystem that the Drupal site is stored within, which is why I’m not developing a module file. Basically, everything I’m trying to implement should be possible just using the admin dashboard. This is also why I’m coding javascript directly into a PHP field.
My question is what is going wrong with the call to AWS, and why is adding the src in the first script tag not enough?