I created API in Laravel. Friend that created Mobile app says that he can connect with my data but he requires it to be in JSON format. Here comes my question. Is there any way to change data to JSON format in Api??
Strange is that API gets result in JSON(at least that's what is says)
Example of data in API results
Should I change my API to JSON:API for this to work?
My database works on MySQL if that might be necessary.
My Api routes:
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
return $request->user();
});
// Events
Route::get('/events', function(){
$date = Carbon::now();
return Event::where('date_of_event','>=',$date)->get();
});
Route::get('/events/{id}', function($id){
return Event::findOrFail($id);
});
// Cities
Route::get('/cities', function(){
return City::all();
});
Route::get('/cities/{id}', function($id){
return City::findOrFail($id);
});
// Clubs
Route::get('/clubs', function(){
return Club::all();
});
Route::get('/clubs/{id}', function($id){
return Club::findOrFail($id);
});
I use ->json() on the response, there are sure other ways to do it globally.
return response()->json($message);