lundi 19 septembre 2022

Correct way to respond from REST api calls + WebSockets?

On certain routes in my app, I have the current implementation at the moment.

API call -> do something -> error occurs -> return with proper error

API call -> do something -> no errors -> respond with 204 -> send WebSocket/PubSub notification with successful response + data

This approach allows me to notify anybody looking at the same page (like 2 people looking at the same order) of the status change, etc and if an error happens only the initiator sees it and deals with it.

Something about this feels wrong. Is there a more correct approach to achieve similar results?

Aucun commentaire:

Enregistrer un commentaire