Answer the question
In order to leave comments, you need to log in
What code should the post method return if nothing has been added to the database?
I have a method that adds an object to the database, but what to return if nothing has been added to the database?
Answer the question
In order to leave comments, you need to log in
As I understand it, this happens when requested by Ajax, or am I not understanding correctly?
If yes, then somehow it is not very informative to return the status of the server response. This information is for the browser, not for the code, and you need to get some kind of meaningful answer in the code. It would be logical to return the number/index of the added object(s). Then it is logical to return zero.
if there is an error when inserting then "500 error description"
is the most normal behavior.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question