- recherche de livre
This commit is contained in:
@ -5,9 +5,10 @@ namespace App\Controller;
|
|||||||
use App\Service\GoogleBooksService;
|
use App\Service\GoogleBooksService;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
|
||||||
class APITestController extends AbstractController
|
class APISearchController extends AbstractController
|
||||||
{
|
{
|
||||||
private GoogleBooksService $googleBooksService;
|
private GoogleBooksService $googleBooksService;
|
||||||
|
|
||||||
@ -16,10 +17,19 @@ class APITestController extends AbstractController
|
|||||||
$this->googleBooksService = $googleBooksService;
|
$this->googleBooksService = $googleBooksService;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/api/search', name: 'api_search')]
|
public function search(): array
|
||||||
public function search(): JsonResponse
|
|
||||||
{
|
{
|
||||||
$results = $this->googleBooksService->searchBooks('Le loup des steppes');
|
return $this->googleBooksService->searchBooks('Le loup des steppes');
|
||||||
return $this->json($results);
|
}
|
||||||
|
|
||||||
|
#[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