@vesperjs/nuxt 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -29,8 +29,11 @@ interface SearchParams {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export type QueryAPIOptions = {
|
|
32
|
+
method?: 'get' | 'query'
|
|
32
33
|
key?: MaybeRefOrGetter<string>
|
|
33
34
|
query?: SearchParams
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
|
+
body?: Record<string, any> | FormData
|
|
34
37
|
token?: string | null
|
|
35
38
|
baseURL?: string | null
|
|
36
39
|
signal?: AbortSignal
|
|
@@ -85,14 +88,27 @@ export const useQueryApi = async function <T = unknown, E = any>(
|
|
|
85
88
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
89
|
const queryOptions: FetchOptions<'json', any> = {
|
|
87
90
|
baseURL: options?.baseURL ?? baseUrl.value,
|
|
88
|
-
method: 'get',
|
|
89
|
-
query: options?.query ?? {},
|
|
90
91
|
headers,
|
|
91
92
|
onResponse({ response }: { response: FetchResponse<T> }) {
|
|
92
93
|
tokenRef.value = response.headers.get('Authorization')?.split(' ')[1] ?? options?.token
|
|
93
94
|
},
|
|
94
95
|
}
|
|
95
96
|
|
|
97
|
+
if (options?.method) {
|
|
98
|
+
queryOptions.method = options.method
|
|
99
|
+
|
|
100
|
+
if (options.method === 'get') queryOptions.query = options.query ?? {}
|
|
101
|
+
if (options.method === 'query') queryOptions.body = options.body ?? {}
|
|
102
|
+
} else {
|
|
103
|
+
if (options?.query) {
|
|
104
|
+
queryOptions.method = 'get'
|
|
105
|
+
queryOptions.query = options.query
|
|
106
|
+
} else if (options?.body) {
|
|
107
|
+
queryOptions.method = 'query'
|
|
108
|
+
queryOptions.body = options.body
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
96
112
|
if (options?.retry) queryOptions.retry = options.retry
|
|
97
113
|
if (options?.retryDelay) queryOptions.retryDelay = options.retryDelay
|
|
98
114
|
if (options?.retryStatusCodes) queryOptions.retryStatusCodes = options.retryStatusCodes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesperjs/nuxt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"nuxt",
|
|
6
6
|
"vue.js"
|
|
@@ -24,16 +24,16 @@
|
|
|
24
24
|
"@nuxt/eslint": "1.15.2",
|
|
25
25
|
"@nuxtjs/i18n": "^10.3.0",
|
|
26
26
|
"@types/node": "^24.12.2",
|
|
27
|
-
"@vesperjs/shared": "0.
|
|
27
|
+
"@vesperjs/shared": "0.6.0",
|
|
28
28
|
"eslint": "^10.3.0",
|
|
29
29
|
"eslint-typegen": "2.3.1",
|
|
30
30
|
"nuxt": "^4.3.1",
|
|
31
31
|
"ofetch": "^1.5.1",
|
|
32
|
-
"oxfmt": "^0.
|
|
32
|
+
"oxfmt": "^0.48.0",
|
|
33
33
|
"typescript": "^6.0.3"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"vue": "^3.5.
|
|
36
|
+
"vue": "^3.5.34 || ^3.6.0-beta.10"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"dev": "nuxi dev .playground",
|