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; }); }