Wrong response format in Laravel

When you get this error in the console that mean you are returning other type of response in the controller like Boolean or Array.

You may code like this.

To get rid of this error, you should transform it to JSON format before returning it. Use response() helper function you can avoid this issue.