Skip to content

Commit db42c63

Browse files
committed
Merge branch 'fix/unhandled-fetch-errors' into 'master'
fix: fetch failed on connection refused calls See merge request postgres-ai/database-lab!459
2 parents d63a96e + 1ed242b commit db42c63

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

ui/packages/ce/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@
5252
"stylelint-config-standard-scss": "^2.0.1",
5353
"stylelint-prettier": "^2.0.0"
5454
},
55-
"proxy": "https://sss.aws.postgres.ai"
55+
"proxy": "https://nik-tf-test.aws.postgres.ai:446/api"
5656
}

ui/packages/shared/helpers/request.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,29 @@ const serializeParams = (params: RequestParams | null) => {
1919
return searchParams.toString()
2020
}
2121

22-
const createUrl = (
23-
path: string,
24-
params: RequestParams | null,
25-
) => {
22+
const createUrl = (path: string, params: RequestParams | null) => {
2623
const serializedParams = serializeParams(params)
2724
const queryString = serializedParams ? `?${serializedParams}` : ''
2825
return `${path}${queryString}`
2926
}
3027

31-
export const request = (path: string, options?: RequestOptions) => {
28+
export const request = async (path: string, options?: RequestOptions) => {
3229
const { params = null, ...requestInit } = options ?? {}
3330

3431
const url = createUrl(path, params)
3532

36-
return window.fetch(url, {
37-
...requestInit,
38-
headers: {
39-
'Content-Type': 'application/json',
40-
...requestInit?.headers,
41-
},
42-
})
33+
try {
34+
return await window.fetch(url, {
35+
...requestInit,
36+
headers: {
37+
'Content-Type': 'application/json',
38+
...requestInit?.headers,
39+
},
40+
})
41+
} catch (e) {
42+
return new Response(null, {
43+
status: 500,
44+
statusText: `Unknown error`,
45+
})
46+
}
4347
}

0 commit comments

Comments
 (0)