1

In API application I want to customize http errors (like 404, 500 or other http errors) I want to respond in this format

return response()->json(['message' => '', 'data' => null, 'result' => false],[specific error code]);

instead of showing laravel default error page enter image description here

how can I do that??

0

2 Answers 2

0

Create a file called 404.blade.php in this /resources/views/errors/ folder.
You can write whatever html you choose in this file to display to your users, and now when you get the 404 error this page will show to you
For other error pages
For example for 500 error page just create this file 500.blade.php, that it

Sign up to request clarification or add additional context in comments.

Comments

-1

enter this command, and the views of errors will be available to edit, in the views file.

php artisan vendor:publish --tag=laravel-errors

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.