xxxxxxxxxx
return response()->json(['success' => true, 'data' => $res], 200);
xxxxxxxxxx
//json encode
return response()->json([
'name' => 'Abigail',
'state' => 'CA',
]);
//now decode
$response = json_decode($response->getContent()) ;
xxxxxxxxxx
return response()->json($array, 202,
[
'Content-Type' => 'application/json',
'Charset' => 'utf-8'
], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
}
xxxxxxxxxx
//Get output from your browser network.
return response()->json([$laravelVariable]);
xxxxxxxxxx
return Response::json([
'hello' => $value
], 201); // Status code here
xxxxxxxxxx
public function store(CreateEvent $request)
{
return response()->json($request->all());
}
xxxxxxxxxx
Route::get('/status', function () {
return response(["success" => true])->header('Content-Type', 'application/json');
});
xxxxxxxxxx
public function getOrgById(Request $request){
// do something here...
return response()->json(array('foo' => 'bar'));
}