I use axios to post username and password to express backend. In the backend I check whether the username already exists, if the username already exists I send json to the frontend. I tried sending res.status(409).json({username_exists: true})
, but I got an error. Then I tried sending exactly the same response but with the status code 200 and it worked.
Why does status(409)
give an error?
I read here on stackoverflow that the status code should be 409 if the username already exists, which status code to send so that the frontend receives the json?