gpt4 book ai didi

reactjs - 在 ReactJS 中使用 Lambda/API 网关

转载 作者:行者123 更新时间:2023-12-04 07:52:01 25 4
gpt4 key购买 nike

我与我的高级项目团队在 AWS Amplify 上的 ReactJS 中设计了一个前端,并希望从 API Gateway 引入数据。我部署了一个链接,我在 AWS 控制台上的 Lambda 中对其进行了测试,该链接工作正常。我正在寻找一些关于将数据从该 url 提取到前端以用于列表的指导。如果您愿意,我可以提供更多信息,请告诉我您需要什么,任何提示都会很棒!谢谢你。

最佳答案

假设:
正如你的问题中提到的,我假设你已经知道如何创建 API 网关,部署 API,现在你有 API 网关 url 来访问其余的 API。
将数据提取到 react 中:
您有以下 cruds API 的示例

     GET /students         List all students
GET /students/1 Load a studentsby id
POST /students Create a students
PUT /students Update a students
DELETE /students/1 Delete a students by id
enter image description here
获取数据:
           import { API } from 'aws-amplify';
API.get('students', '/students', {}).then(result => {
this.todos = JSON.parse(result.body);
}).catch(err => {
console.log(err);
})
安全:
您需要使用 API key 或授权方来保护其余 API
enter image description here
  • https://github.com/vaquarkhan/aws-amplify-workshop-react
  • https://www.freecodecamp.org/news/going-serverless-with-react-and-aws-amplify-part-2-creating-and-using-serverless-services-d401ba346eeb/
  • https://gerard-sans.medium.com/create-a-rest-api-integrated-with-amazon-dynamodb-using-aws-amplify-and-vue-5be746e43c22
  • 关于reactjs - 在 ReactJS 中使用 Lambda/API 网关,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66912916/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com