- recherche de livre
This commit is contained in:
@ -5,9 +5,10 @@ namespace App\Controller;
|
||||
use App\Service\GoogleBooksService;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class APITestController extends AbstractController
|
||||
class APISearchController extends AbstractController
|
||||
{
|
||||
private GoogleBooksService $googleBooksService;
|
||||
|
||||
@ -16,10 +17,19 @@ class APITestController extends AbstractController
|
||||
$this->googleBooksService = $googleBooksService;
|
||||
}
|
||||
|
||||
#[Route('/api/search', name: 'api_search')]
|
||||
public function search(): JsonResponse
|
||||
public function search(): array
|
||||
{
|
||||
$results = $this->googleBooksService->searchBooks('Le loup des steppes');
|
||||
return $this->json($results);
|
||||
return $this->googleBooksService->searchBooks('Le loup des steppes');
|
||||
}
|
||||
|
||||
#[Route('/api/search', name: 'api_search')]
|
||||
public function index(): Response
|
||||
{
|
||||
$datas = $this->search();
|
||||
|
||||
return $this->render('apiSearch/index.html.twig', [
|
||||
'controller_name' => 'APISearchController',
|
||||
'datas' => $datas,
|
||||
]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user