Skip to content
This repository was archived by the owner on Oct 9, 2024. It is now read-only.

Commit 8cd0a50

Browse files
committed
feat(composables): 🔊 add error log in useBackend
1 parent 6f2bc13 commit 8cd0a50

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

‎composables/useBackend.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,26 @@ export const useBackend = () => {
99
* @param data Data.
1010
*/
1111
async function request(method: HTTPMethod, path: string, data: object = {}) {
12-
return await $fetch(useRuntimeConfig().public.backend.url + path, {
13-
method: method,
14-
headers: {
15-
"Authorization": useRuntimeConfig().public.backend.authorization,
16-
},
17-
body: method === "PUT" ? data : undefined,
18-
});
12+
try {
13+
return await $fetch(useRuntimeConfig().public.backend.url + path, {
14+
method: method,
15+
headers: {
16+
"Authorization": useRuntimeConfig().public.backend.authorization,
17+
},
18+
body: method === "PUT" ? data : undefined,
19+
});
20+
} catch (e) {
21+
console.error(e);
22+
return {};
23+
}
1924
}
2025

2126
/**
2227
* Fetch votes.
2328
* @returns {Promise<PluginVotesSummary>} PluginVotesSummary.
2429
*/
2530
async function fetchVotes(): Promise<PluginVotesSummary> {
26-
try {
27-
return await request("GET", "") as PluginVotesSummary;
28-
} catch (e) {
29-
return {};
30-
}
31+
return await request("GET", "") as PluginVotesSummary;
3132
}
3233

3334
/**

0 commit comments

Comments
 (0)