Getting a List of Customer Records
Last updated
Last updated
If the access token is obtained successfully, redirect the user to the Customers screen of the application. When the customers page is loaded, call the GET_CUSTOMERS api to get a list of all the customers
Request URL: https://api.eng-dev-1.trilloapps.com/ds/function/shared/GetCustomers
Showing customer records on the screen involves creating a user-friendly and secure experience. Below are key points to consider when implementing a "Customer Records" screen:
Design the customer record screen to provide a concise and organized overview. Include key information, such as:
Customer names
Email, Phone
Address
Status (Active, Inactive)
Implement search options to help users quickly find specific customer records based on customer names.
Pagination
If the customer record list is extensive, pagination is implemented to display records in smaller, more manageable chunks.
The getCustomersData retrieves customer information from a database. It's a function designed to fetch and provide relevant data about customers, facilitating personalized services or analytics in various applications.
API Request
Invokes the apiService.getCustomers(start, size) method to make an asynchronous request to the server to fetch customer data. The start and size parameters likely control the pagination of the data.
Handling API Response
Uses the then method to handle the response from the API request asynchronously.
Check if the response status is 'failed', log the error message to the console, and display a danger toast with the error message.
Update Global Data
If the response status is ‘not failed', update the global customerDataList with the customer data received from the response.
Calculates the total number of pages (totalPages) based on the total data count and the number of items per page (itemsPerPage).
Populate Table and Pagination
Calls the populateTable function to update the table with the retrieved customer data.
Calls the generatePagination function to create pagination links based on the total number of pages.
Error Handling
Uses the catch block to handle any errors that may occur during the API request and displays a danger toast with the error message.