4daebf8c-dc42-4579-b104-0ed8afe17301 — Commit 81849908

AuthorMikkel Thygesen<Mikkelet@gmail.com>
Date2026-05-16 18:47:08 +0200
Added better error handling

Changed files

src/api/client.ts        | 30 +++++++++++++++++-------------
 src/views/AddAppView.vue |  7 ++++++-
 2 files changed, 23 insertions(+), 14 deletions(-)

Diff

diff --git a/src/api/client.ts b/src/api/client.ts
index fa4fbb8..5ea7454 100644
--- a/src/api/client.ts
+++ b/src/api/client.ts
@@ -24,11 +24,13 @@ api.interceptors.response.use(
const {config, response} = error
const method = config?.method?.toUpperCase() ?? 'REQUEST'
const url = config?.url ?? ''
- if (response) {
+ const data = response.data
+ console.error({"data": data})
+ if (data) {
console.error(`[API] ${method} ${url} → ${response.status} ${response.statusText}`, response.data)
- } else {
- console.error(`[API] ${method} ${url} → network error`, error.message)
+ return Promise.reject(Error(data.toString()))
}
+ console.error(`[API] ${method} ${url} → network error`, error.message)
return Promise.reject(error)
},
)
@@ -60,11 +62,14 @@ export const createApp = (
export const getApp = (orgId: string, appId: string) =>
api.get<ApiApp>(`/organizations/${orgId}/apps/${appId}`).then(r => normalizeApp(r.data))
-export const updateApp = (
+export async function updateApp(
orgId: string,
appId: string,
data: { name: string; environments: Record<string, string> }
-) => api.put<ApiApp>(`/organizations/${orgId}/apps/${appId}`, data).then(r => normalizeApp(r.data))
+): Promise<App> {
+ const response = await api.put<ApiApp>(`/organizations/${orgId}/apps/${appId}`, data)
+ return normalizeApp(response.data)
+}
export const deleteApp = (orgId: string, appId: string) =>
api.delete(`/organizations/${orgId}/apps/${appId}`)
@@ -91,18 +96,17 @@ export const getDeeplink = (orgId: string, appId: string, deeplinkId: string) =>
)
.then(r => r.data)
-export const updateDeeplink = (
+export async function updateDeeplink(
orgId: string,
appId: string,
deeplinkId: string,
data: Omit<DeeplinkTemplate, 'id' | 'appId'>
-) =>
- api
- .put<DeeplinkTemplate>(
- `/organizations/${orgId}/apps/${appId}/deeplinks/${deeplinkId}`,
- data
- )
- .then(r => r.data)
+) {
+ const url = `/organizations/${orgId}/apps/${appId}/deeplinks/${deeplinkId}`
+ const response = await api.put<DeeplinkTemplate>(url, data)
+ return response.data
+}
+
export const deleteDeeplink = (orgId: string, appId: string, deeplinkId: string) =>
api.delete(`/organizations/${orgId}/apps/${appId}/deeplinks/${deeplinkId}`)
diff --git a/src/views/AddAppView.vue b/src/views/AddAppView.vue
index c7fe686..2ba489d 100644
--- a/src/views/AddAppView.vue
+++ b/src/views/AddAppView.vue
@@ -74,7 +74,12 @@ async function handleSubmit() {
router.push(`/org/${orgId}/app/${app.id}`)
}
} catch (e: unknown) {
- error.value = e instanceof Error ? e.message : 'Failed to save app'
+ if(e instanceof Error) {
+ error.value = e.message
+ } else {
+ console.error(e)
+ error.value = "Failed to save app"
+ }
} finally {
loading.value = false
}