Amazon DynamoDB and AngularJS

前端 未结 2 1836
难免孤独
难免孤独 2021-02-06 09:42

So, I created an AWS dynamoDB table (database) and I am ready to get that data with AngularJS. How do I do this with AngularJS? Do I need to setup another service with Amazon? O

2条回答
  •  南方客
    南方客 (楼主)
    2021-02-06 10:19

    Yes, you can access Amazon DynamoDB directly from your AngularJS application using the AWS JavaScript SDK for the Browser. The same code snippet should work for NodeJS as well.

    One thing to note is that your application needs to securely authenticate to AWS without embedding security credentials in the code. Amazon Cognito makes it easy and automatically takes care of authentication if you have created an identity pool and configure your application accordingly. Here are some links that will help you get started. We built a demo application with AngularJS on Amazon DynamoDB. It uses Amazon Cognito for authentication and the Document SDK to store and retrieve JSON objects to and from DynamoDB directly, without needing to serialize and deserialize them in client code in the browser.

    Source code: https://github.com/awslabs/aws-dynamodb-mars-json-demo

    Live demo: http://dynamodb-msl-image-explorer.s3-website-us-east-1.amazonaws.com/

    examples of using the AWS library: https://github.com/awslabs/aws-dynamodb-mars-json-demo/blob/master/viewer/app/scripts/services/mars-photos.js

    examples of using the service that is using the AWS library: https://github.com/awslabs/aws-dynamodb-mars-json-demo/blob/master/viewer/app/scripts/controllers/favorites.js

    https://github.com/awslabs/aws-dynamodb-mars-json-demo/blob/master/viewer/app/scripts/controllers/top-voted.js

    Document SDK: https://github.com/awslabs/dynamodb-document-js-sdk

提交回复
热议问题