use Illuminate\Support\Facades\Response;
Route::get('/resp-json',function() {
$jsonData = [
[
'id'=>1,
'title'=>'Title 1',
'body' =>'Message details 1',
],
[
'id'=>2,
'title'=>'Title 2',
'body' =>'Message details 5',
],
[
'id'=>3,
'title'=>'Title 3',
'body' =>'Message details 5',
],
[
'id'=>4,
'title'=>'Title 4',
'body' =>'Message details 5',
],
[
'id'=>5,
'title'=>'Title 5',
'body' =>'Message details 5',
],
];
return Response::json($jsonData);
// OR
// return response()->json($jsonData);
});
Route::get('/resp-json',function() {
$jsonData = [
[
'id'=>1,
'title'=>'Title 1',
'body' =>'Message details 1',
],
[
'id'=>2,
'title'=>'Title 2',
'body' =>'Message details 5',
],
[
'id'=>3,
'title'=>'Title 3',
'body' =>'Message details 5',
],
[
'id'=>4,
'title'=>'Title 4',
'body' =>'Message details 5',
],
[
'id'=>5,
'title'=>'Title 5',
'body' =>'Message details 5',
],
];
return Response::json($jsonData);
// OR
// return response()->json($jsonData);
});
OUTPUT:
0 comments:
Post a Comment