xxxxxxxxxx
return response()->json([
'name' => 'Abigail',
'state' => 'CA',
]);
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
return response()->json(['item_image ' => $item_image, 'item_something' => $item_something, 'item_more' => $item_more ]);
xxxxxxxxxx
//Get output from your browser network.
return response()->json([$laravelVariable]);
xxxxxxxxxx
return Response::json([
'hello' => $value
], 201); // Status code here
xxxxxxxxxx
Route::get('/status', function () {
return response(["success" => true])->header('Content-Type', 'application/json');
});