I've got a basic social networking concept: Friend Requests.
Each friend request can either be accepted or declined, either action should result in the friend request being removed from the collection and deleted from the server.
I'm able to use model.destroy()
to issue the DELETE
request to the server and also remove the item from the FriendRequests collection. But I need to send some additional data to the server about whether the Request was accepted or declined. ?accepted=true|false
How do I do send additional data allong with Destroy()
- or am I going about this the wrong way?
I agree with @kinakuta that this is not a standard DELETE. Consider doing a PUT to /friend-request/42/accept
or /friend-request/42/decline
. Another option would be to do a standard update/PUT but on the server take the appropriate action when the accepted
flag is provided during an update. You may also want to implement "soft delete" for your server side database records where the friend request doesn't actually get deleted but has its "status" attribute changed to the appropriate lifecycle value. Could be one of "pending", "declined", "accepted", etc. You may want to store additional metadata like a timestamp when the request was accepted, which could be interesting for reporting/analysis. If you delete the record, there's no convenient place to store that metadata.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With