If I return an object:
return Response::json([
\'hello\' => $value
]);
the status code will be 200. How can I change it to 201, with
I think it is better practice to keep your response under single control and for this reason I found out the most official solution.
response()->json([...])
->setStatusCode(Response::HTTP_OK, Response::$statusTexts[Response::HTTP_OK]);
add this after namespace declaration:
use Illuminate\Http\Response;