You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
708 B
22 lines
708 B
export function search(query, filter, offset, limit, addAlert) {
|
|
return fetch(`/api/search?q=${encodeURIComponent(query)}&type=${filter}&offset=${offset}&limit=${limit}`, {
|
|
method: 'GET',
|
|
credentials: 'include',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
}
|
|
})
|
|
.then((response) => {
|
|
if (!response.ok) {
|
|
throw new Error("Network response was not ok");
|
|
}
|
|
return response.json();
|
|
})
|
|
.catch((error) => {
|
|
console.error("There was a problem with the fetch operation:", error);
|
|
if (addAlert) {
|
|
addAlert('error', 'Erreur lors de la recherche');
|
|
}
|
|
throw error;
|
|
});
|
|
}
|