1. Integrating APIs
1.1 Get Exclusive Prime Deals
- Exclusive Prime deals are for Prime Users.
- All Products are for both Prime and Non-Prime users.
2. API Call Possible Views
2.1 Success View
When the
Prime User
is logged in and accessed Prime Deals
Section then we should show the Exclusive Prime Deals
section.2.2 Failure View
When the
Non-prime User
is logged in and accessed Prime Deals
Section then we should show the Get Exclusive Deals
section.Reasons for API Call Failure :
- Sending UnAuthorized User credentials
- Not specifying Authorization header
- Using the wrong HTTP method
2.3 Loading View
When the
Prime
or Non-prime User
is logged in and accessed Prime Deals
Section, we should show the Loading view
until data is in progress.3. E-Commerce Application
4. Best Practices
4.1 State Variable-isLoading
isLoading is used to handle Success View, Loading View only.
JSX
4.2 State Variable-apiStatus
apiStatus is used to handle Success, Failure and Loading Views.
JSX
4.3 Adding Initial State
Instead of adding empty strings in initial state we can add initial in apiStatusConstants.
File: src/components/PrimeDealsSection/index.js
JSX