Skip to content

Commit fbf78c5

Browse files
committed
chore: wip
1 parent a0498c0 commit fbf78c5

File tree

7 files changed

+3972
-2
lines changed

7 files changed

+3972
-2
lines changed

storage/framework/core/composables/src/useFetch.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,20 @@ export function useFetch(url: string): FetchBuilder {
6565
const error = ref<any>(null)
6666
const isFetching = ref(true)
6767

68+
let parsedBody: any
69+
if (body) {
70+
try {
71+
parsedBody = JSON.parse(body)
72+
}
73+
catch {
74+
parsedBody = body
75+
}
76+
}
77+
6878
const fetchPromise = client.request(url, {
6979
method,
7080
json: method !== 'GET' && method !== 'DELETE',
71-
body: body ? JSON.parse(body) : undefined,
81+
body: parsedBody,
7282
headers: {
7383
Accept: 'application/json',
7484
},

storage/framework/core/composables/src/useImage.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,15 @@ export function useImage(options: UseImageOptions): UseImageReturn {
3838

3939
img.onerror = (e) => {
4040
isLoading.value = false
41-
error.value = typeof e === 'string' ? e : 'Failed to load image'
41+
if (typeof e === 'string') {
42+
error.value = e
43+
}
44+
else if (e instanceof Event && e.type === 'error') {
45+
error.value = `Failed to load image: ${options.src}`
46+
}
47+
else {
48+
error.value = 'Failed to load image'
49+
}
4250
}
4351

4452
if (options.crossorigin)

0 commit comments

Comments
 (0)