Apr 17, 2020
0
Level 5
How to return status API
Hey guys
I would like to know how to return directly responses in API..
I mean let's say I'm fetching a user and I return 404 if he doesn't exist..
My response from the backend would be
$response->json(['status' => 404]);
so server returns 200 meaning it's fetched but then I have to test on
response.data.status == 404
I want directly something like
response.status == 404
how can I return that ?
I hope it's clear
Please or to participate in this conversation.