Test APIs with front-end

After testing that the APIs work properly with Postman, we will test the APIs that are called with the front-end built from part 2.

  1. Open config.js in fcj-serverless-frontend folder that downloaded from part 2.

    • Change value of APP_API_URL with your URL. CreateRestAPI CreateRestAPI
  2. Open App.js in fcj-serverless-frontend/src/, change value of isAdmin with true. CreateRestAPI

  3. Run the code below in your terminal.

    yarn build
    aws s3 rm s3://fcj-book-shop-by-myself --recursive
    aws s3 cp build s3://fcj-book-shop-by-myself --recursive
    
  4. Paste the endpoint of S3 static web into your browser. The app already shows the book information, but still no pictures because we haven’t uploaded the pictures yet. CreateRestAPI So the listing API is working properly.

  5. Test writing API.

    • Click Management tab.
    • Click Update. CreateRestAPI
    • Edit whatever you want except id.
    • Click Choose image.
    • Upload the below image to the bucket:
    • Click Update.
    • Click OK. CreateRestAPI
    • Image and information updated. CreateRestAPI
    • Click on the Create new book tab to write new data to the database.
    • Enter id with 5
    • Enter name: Amazon Web Services in Action
    • Enter the author: Andreas Wittig
    • Enter category: IT
    • Enter price: 59.99
    • Enter a description: Amazon Web Services in Action, Second Edition is a comprehensive introduction to computing, storing, and networking in the AWS cloud. You'll find clear, relevant coverage of all the essential AWS services you to know, emphasizing best practices for security, high availability, and scalability.
  6. aws.jpg (24 ko)
    • Press the Choose File button to upload the image.
    • Press the Create button.
    • Click OK. CreateRestAPI
    • Display newly created information. CreateRestAPI
  7. Test the deleting API.

    • Click Management tab.
    • Click Update. CreateRestAPI
    • Click Delete.
    • Click OK to confirm delete. CreateRestAPI
    • View results after deleting: no appearing book information. CreateRestAPI

We have finished building a simple SAM-based web application following the serverless model.