Toggle favorite working
This commit is contained in:
parent
5e3f4ec621
commit
4ea2871c6d
13 changed files with 300 additions and 169 deletions
|
|
@ -97,5 +97,28 @@ export const useApiStore = defineStore("api", () => {
|
|||
});
|
||||
}
|
||||
|
||||
return { fetchDataThroughKQL, fetchPageData };
|
||||
async function fetchRoute(path, method, data) {
|
||||
const config = {
|
||||
method: method,
|
||||
};
|
||||
|
||||
if (data) {
|
||||
config.body = JSON.stringify(data);
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(path, config);
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
const data = await response.json();
|
||||
console.log("La route " + path + " a fonctionné.");
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error("La route " + path + " n'a pas fonctionné.", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
return { fetchDataThroughKQL, fetchPageData, fetchRoute };
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue