Create & Interact with a Serverless REST API with AWS Lambda from React

Instructornader dabit

Share this video with your friends

Send Tweet

In this lesson we’ll learn how to create a Lambda function and use AWS Amplify to interact with the Lambda function from a React app. Lambda functions allow us to easily create one off functionality or interact with microservices. We’ll use the Lambda function to translate text from english to spanish.

Gerardo
~ 5 years ago

Thanks Nader, as always amazing explanations. Just found 2 small typos on the code:

  1. An extra dot at the Const declaration const.people = [ ]
  2. An extra semicolon in the Axios success response people:
Gerardo
~ 5 years ago

Note: the typo is in the transcripted code, not on the code in the video.

moshe pinhasi
~ 5 years ago

This is a great video!

Can I serve static from the backend function (for server side rendering case)? If yes, how can I do that? where should I put the static files?

nader dabitinstructor
~ 5 years ago

Can I serve static from the backend function (for server side rendering case)? If yes, how can I do that? where should I put the static files?

Yes, you can do this. As long as the files are located in the main project root, it should work. Gatsby is a popular use case for this.

Ben
~ 5 years ago

AppSync now has functions

Babs Craig
~ 5 years ago

Ran into an issue where the amplify push command didn't work after setting up the api. I ran amplify-init again and this seemed to solve the issue. In case you also run into it, find reference here: https://github.com/aws-amplify/amplify-cli/issues/195

Luis
~ 5 years ago

I get a 502 while making a get call on peopleapi. Would anyone be able to help

Luis
~ 5 years ago

never mind it was a silly mistake on my end

Eyas Tayyem
~ 5 years ago

I keep getting a 403 Error message Access to XMLHttpRequest at 'https://8w9xad2in3.execute-api.us-west-2.amazonaws.com/amplifyapp/people' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. I've created a user with an authentication token and signed in. Any idea what could be the issue here?

Xavier Brinon
~ 5 years ago

https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-cors.html

Joe Seifi
~ 5 years ago

I'm running into an issue with authentication enabled, and getting a 403 on the endpoint. In API Gateway I am seeing "Auth: AWS_IAM" for both of the ANY endpoints, and I am logged into the app using the withAuthenticator HOC. Seems like somehow the app isn't either looking for the logged in token, not passing it, or not honoring it.

Any ideas?

Mateusz Angulski
~ 5 years ago

CORS is set up by default in app.js in the express app. It's the issue with aws role not having access to the execute-api:Invoke action. Please try to do the failing GET request in postman or curl and there you can see what role is missing which action for what resource. In my case it was adding this policy to one of the roles: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-iam-policy-examples-for-api-execution.html First one at the top.

Mason Jennings
~ 3 years ago

Looks like the star wars api address has been updated to swapi.dev