- Using REST API calls
{
"data": {
"name": "John",
"age": 26,
...
}
}
Success
{
"status": "sucess"
}
Failure
{
"status": "error",
"error": {
"message": "Customer already exists"
}
}
- Faster from both client side and server side
- Easier implementation and moving parts in code
- Ideal if client side dont need further data from backend to show the grid
- If there are additional data in the response you need in the grid(like "id" field which would be generated at the db side), it could not be shown in the front-end
{
"data": {
"name": "John",
"age": 26,
...
}
}
Success
{
"status": "success",
"data": {
"id": 123
"name": "John",
"age": 26,
}
}
Failure
{
"status": "error",
"error": {
"message": "Customer already exists"
}
}
- Faster from both client side and server side
- Easier implementation and moving parts in code
- Fetch more data from backend as required(ex, "id" field)
- As the data(columns in this case) grows, the response grows as well. Not really that much big of a deal to be honest.
{
"data": {
"name": "John",
"age": 26,
...
}
}
Success
{
"status": "sucess",
"data": {
"id": 123
}
}
Failure
{
"status": "error",
"error": {
"message": "Customer already exists"
}
}
{
"data": {
"id": 123
}
}
Success
{
"status": "success",
"data": {
"id": 123
"name": "John",
"age": 26,
}
}
- None I can think of
- Both server side and client side need to handle multiple requests for a single operation, meaning more moving parts, which translates to more errors and edge cases(For example, what do you show on the client side, if the first call is success, but second call fails?).
- Laggy user experience(based on latency of these calls)
- Higher implementation cost