- recherche de livre

This commit is contained in:
2025-01-29 10:26:07 +01:00
parent 6f78a8a4a3
commit 45362ae9d9
2 changed files with 15 additions and 5 deletions

View File

@ -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,
]);
}
}