From a2d42aaa6124bc6f26201feec755a1bbcf939a17 Mon Sep 17 00:00:00 2001 From: Florian Sylvain Date: Fri, 7 Jan 2022 18:07:45 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20error=20when=20search=20?= =?UTF-8?q?too=20short?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjetProgWeb/app.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ProjetProgWeb/app.js b/ProjetProgWeb/app.js index b2ed48b..033f232 100644 --- a/ProjetProgWeb/app.js +++ b/ProjetProgWeb/app.js @@ -72,7 +72,13 @@ function apiRequestThese(search, offset) { .then(data => { fetch(`api.php?q=count&search=${searchString}&option=${queryOption}&offset=0`) .then(response => response.json()) - .then(aCount => displayResults(data, aCount.data[0])) + .then(aCount => { + if (aCount.data) { + displayResults(data, aCount.data[0]) + } else { + displayResults(data, 0) + } + }) }) } else { alert('Veuillez attendre une seconde entre chaque recherche.')