@vesperjs/nuxt 0.3.2 → 0.3.3
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.
|
@@ -9,6 +9,7 @@ interface MutationAPIOptions {
|
|
|
9
9
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
10
|
body?: Record<string, any> | FormData
|
|
11
11
|
token?: string | null
|
|
12
|
+
baseURL?: string | null
|
|
12
13
|
onRequestError?: ({ error }: { error: Error }) => void
|
|
13
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
15
|
onResponseError?: ({ response }: { response: FetchResponse<any> }) => void
|
|
@@ -17,7 +18,14 @@ interface MutationAPIOptions {
|
|
|
17
18
|
// eslint-disable-next-line
|
|
18
19
|
export const useMutationApi = async function <T = unknown, E = any>(
|
|
19
20
|
url: string,
|
|
20
|
-
{
|
|
21
|
+
{
|
|
22
|
+
method,
|
|
23
|
+
body = {},
|
|
24
|
+
token = null,
|
|
25
|
+
baseURL = null,
|
|
26
|
+
onRequestError,
|
|
27
|
+
onResponseError,
|
|
28
|
+
}: MutationAPIOptions,
|
|
21
29
|
): Promise<{
|
|
22
30
|
token: string | null | undefined
|
|
23
31
|
data: T | undefined
|
|
@@ -25,7 +33,7 @@ export const useMutationApi = async function <T = unknown, E = any>(
|
|
|
25
33
|
pending: boolean
|
|
26
34
|
}> {
|
|
27
35
|
const { commonHeaders } = useHttpHeaders()
|
|
28
|
-
const { baseURL } = useApiConstants()
|
|
36
|
+
const { baseURL: baseUrl } = useApiConstants()
|
|
29
37
|
|
|
30
38
|
const headers: Record<string, string> = commonHeaders.value
|
|
31
39
|
|
|
@@ -36,7 +44,7 @@ export const useMutationApi = async function <T = unknown, E = any>(
|
|
|
36
44
|
}
|
|
37
45
|
|
|
38
46
|
const options: FetchOptions<'json'> = {
|
|
39
|
-
baseURL: baseURL.value,
|
|
47
|
+
baseURL: baseURL ?? baseUrl.value,
|
|
40
48
|
headers,
|
|
41
49
|
method,
|
|
42
50
|
}
|
|
@@ -17,6 +17,7 @@ export type QueryAPIOptions = {
|
|
|
17
17
|
key?: MaybeRefOrGetter<string>
|
|
18
18
|
query?: SearchParams
|
|
19
19
|
token?: string | null
|
|
20
|
+
baseURL?: string | null
|
|
20
21
|
signal?: AbortSignal
|
|
21
22
|
onRequestError?: ({ error }: { error: Error }) => void
|
|
22
23
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -33,7 +34,7 @@ export const useQueryApi = async function <T = unknown, E = any>(
|
|
|
33
34
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
35
|
const { $api } = useNuxtApp() as any
|
|
35
36
|
const { commonHeaders } = useHttpHeaders()
|
|
36
|
-
const { baseURL } = useApiConstants()
|
|
37
|
+
const { baseURL: baseUrl } = useApiConstants()
|
|
37
38
|
|
|
38
39
|
const key = options?.key ?? url
|
|
39
40
|
|
|
@@ -50,7 +51,7 @@ export const useQueryApi = async function <T = unknown, E = any>(
|
|
|
50
51
|
|
|
51
52
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
53
|
const getOptions: FetchOptions<'json', any> = {
|
|
53
|
-
baseURL: baseURL.value,
|
|
54
|
+
baseURL: options?.baseURL ?? baseUrl.value,
|
|
54
55
|
method: 'get',
|
|
55
56
|
query: options?.query ?? {},
|
|
56
57
|
headers,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesperjs/nuxt",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"nuxt",
|
|
6
6
|
"vue.js"
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@formkit/tempo": "^1.0.0",
|
|
24
24
|
"@nuxt/eslint": "1.15.2",
|
|
25
|
-
"@nuxtjs/i18n": "^10.
|
|
25
|
+
"@nuxtjs/i18n": "^10.3.0",
|
|
26
26
|
"@types/node": "^24.12.2",
|
|
27
|
-
"@vesperjs/shared": "0.3.
|
|
27
|
+
"@vesperjs/shared": "0.3.3",
|
|
28
28
|
"eslint": "^10.2.1",
|
|
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.47.0",
|
|
33
33
|
"typescript": "^6.0.3"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|