3

I have a frontend that I designed in ReactJS on AWS Amplify with my Senior Project team and am looking to bring in data from API Gateway. I have a link I deployed that I tested in Lambda on the AWS console which works correctly. I am looking for some guidance on pulling in the data from that url to the frontend to use for a list. I can supply more information if you would like, please let me know what you need and any tips would be great! Thank you.

2
  • so, you tested api gateway from console, did you try calling api gateway endpoint from postman? Commented Apr 2, 2021 at 1:12
  • @BaluVyamajala Yes both worked correctly. What library would be best for sending queries to the endpoint to populate the frontend? Commented Apr 2, 2021 at 21:05

1 Answer 1

2
+50

Assumption :

As mentioned in your question i assume that you already aware how to create API Gateway,deploy API and now you have API gateway url to access rest API.

Fetch data into react :

Example you have following 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

Fetching data:

           import { API } from 'aws-amplify';
             API.get('students', '/students', {}).then(result => {
             this.todos = JSON.parse(result.body);
              }).catch(err => {
                 console.log(err);
              })

Security :

You need to secure rest API either use API key or Authorizer

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

This is just what I needed! Thank you @vaquar-khan
Can I somehow import generated js SDK from API Gateway into my react application? I saw suggestions to use bundlers, But I don't know how exactly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.