Hello guys.Is it a good idea not to pass error codes like 401, 403, 404 etc like (res.status(404).json(error)) but instead always have a 200 status but use a flag in the response to check whether it was success or reject and message (for example res.json({ success: false, message: "Something went wrong on the server"})) and then catch those messages on the fronted also based on this flag( promise.then(response => { if (response.data.success) }) etc, instead of dealing with errors in catch.Is this bad? I hate having errors in console and dealing with "catch" in the promise and approach i wrote above looks much better to me, easier to handle, and I send my own messages instead of dealing with complex structured, deeply nested error codes and stuff.Thanks!
Submitted February 25, 2018 at 09:31AM by nikola1970
No comments:
Post a Comment