Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extra GET API call after update call

As the frontend application has its own state, now the user updated his/her contact and the frontend state got updated and PUT API is called to update with the current state.

So while updating the user contact details through PUT call, should another GET call be made to fetch the user details or should the current state is enough for the frontend.

Just curious what is the advised pattern to follow.

like image 394
Surabhi K Avatar asked Oct 26 '25 17:10

Surabhi K


2 Answers

Your PUTrequest should send a 200 ok so you know that the data frontside is now valid.

You could of course (this is what I do in some instances), is send the object back as a response of your PUT request with a 200 ok. With this object you can update your view as needed, ensuring that the object is exactly the same as the one on the server side.

A GET is not needed in this case.

like image 152
kemicofa ghost Avatar answered Oct 29 '25 07:10

kemicofa ghost


Another get request is not necessary, If you really want to maintain the state from backend (which is also not necessary), you can respond from the server to the PUT Request with the state. This may come in handy if to know execution is successful.

like image 33
Janith Avatar answered Oct 29 '25 06:10

Janith



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!