0

I am working in Angular project which is connected to REST API. Here we have an endpoint to create and update room types. POST endpoint for create and PUT endpoint for update exiting room types.

Both POST & PUT API endpoints were developed to take one room type at a time as the payload. But frontend angular application allow users to create and edit multiple room type at once. And it has one save button to save all room types.

In that case which one is the best & reliable approach to go forward.

  1. Pick all changes of room types and create payload for each one and send multiple POST or PUT call from frontend application. as an example :- if user edit 10 room type angular app will be sending 10 http calls.

  2. Redesign the REST API call to take the multiple room types as payload. example :- all 10 room type details will be attached to the payload as list and send once.

Kindly have your thoughts on this.

Thanks Nuwan

0

Splitting on the front end is the best solution.

The problems with a bulk update are:

  1. May take a long time with no feed back.
  2. May timeout
  3. if a single item fails out of a list what do you do and how do you communicate it

If you send them all from the front end, then each call has a known performance and you can update the progress as they complete.

If a single item fails then you can show this and take action.

If you need a transaction for the whole list you will have to implement some sort of manual transaction control via rest calls however.

2
  • Hi Ewan. I thought sending multiple call from frontend application adds more latency since each http calls has some amount of latency. Isn't it ?
    – Nuwan
    Jan 20 at 10:06
  • send them all asynchronously
    – Ewan
    Jan 20 at 10:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.