S
S
Sasha Pleshakov2017-05-07 23:30:39
JavaScript
Sasha Pleshakov, 2017-05-07 23:30:39

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

2 answer(s)
T
ThunderCat, 2017-05-08
@ThunderCat

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.

A
Alexander N++, 2017-05-08
@sanchezzzhak

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 question

Ask a Question

731 491 924 answers to any question