Now that we have our three APIs set up, we are ready to call them from a web page. First, we need to set up our single-page web application (SPA) and host it on Amazon S3.
We have decided to use the AngularJS framework for our SPA. You could of course use any suitable framework. The aim of this Lab is not to teach you AngularJS or any other SPA framework, so we won’t be diving into the details of how the page works, other than to guide you through wiring up the API calls that the SPA will need to make to populate its data elements.
The SPA implementation you have been provided has stubbed-out implementations of the three APIs we want to expose to our users. They have just enough implementation to not cause an error on the page when executed, but they do not provide any data. In order to ‘wire up’ our APIs to the SPA, we will need to generate the Javascript client SDKs that relate to these APIs and store them in the appropriate path.


apigClientFactoryapigClientFactory_FlightSpecials
apigClientFactoryapigClientFactory_HotelSpecialsapigClientFactoryapigClientFactory_TripSearchWith the API SDKs in place, you are now ready to deploy the SPA code to the Amazon S3 Bucket that will serve the website. The lab setup process has provisioned a suitable S3 bucket, with WebSite Hosting enabled. So you will only need to push all the files from your local machine to the S3 bucket to be able to test the application.
set AWS_PROFILE=devaxacademy
aws s3 sync . s3://<S3BucketWWWBucketName> --acl public-read
Replace <S3BucketWWWBucketName> with the S3BucketWWWBucketName value in the Output tab of the DevAx-06 stack
18. When the synchronize has completed, you are ready to test your SPA hosted on S3. Open the following URL in the web browser
http://<S3BucketWWWBucketName>.s3-website-<YOUR_REGION>.amazonaws.com
Repalce <S3BucketWWWBucketName> with the S3BucketWWWBucketName value in the Output tab of the DevAx-06 stack
Repalce <YOUR_REGION> with your Region
The familiar TravelBuddy website should render in your browser. Previously you have seen this website when it was served from a monolithic Java application served off EC2 managed by Elastic Beanstalk. But now, the site is a single-page web application, and is hosted from an S3 bucket, making API calls to Amazon API Gateway to provide data to the website.
You should see the Hotel Specials and Flight Specials listings rendered on the page.
In addition, a Find trips to… option is available. To test this, enter Melbourne in the text field and click the Go! button. A dialog will appear showing the results of the search. This data is being served from a call to the TripSearchAPI call, for /tripsfromcity.

If you clear the value in the field and click the Go! button, you will see a list of all available trips, which is served from the TripSearchAPI call for /trips.

If you are not seeing the data as a result of the API calls, take a look at the developer console in the browser, to see if there are any errors that will help track down the issue.