I would like to know what is the best practice for the following use case: There is a person object:
{
id: number;
firstName: string;
lastName: string;
phoneNumber: string;
address: string
/* more fields */
}
I need to fetch list of people and in the list I only need to display part of the object fields (for example - first and last name), after that the user can choose one from the list which will go to another screen where the person details will be fully displayed (for example - also address, phone number, etc).
Should I fetch from the beginning the whole fields for each person or fetch only necessary fields and fetch the whole data for a specific person only when it is needed?
Are there any best practices rules regarding this?
CodePudding user response:
Every unnecessary field increases computational time, traffic, latency. You should fetch only necessary fields and then wait for client to request more info.