File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -35,9 +35,6 @@ import type { OpenAPIConfig } from './OpenAPI';
35
35
{{> functions/getQueryString }}
36
36
37
37
38
- {{> functions/getUrl }}
39
-
40
-
41
38
{{> functions/getFormData }}
42
39
43
40
@@ -61,6 +58,23 @@ import type { OpenAPIConfig } from './OpenAPI';
61
58
62
59
{{> functions/catchErrorCodes }}
63
60
61
+ const getUrl = (config: OpenAPIConfig, options: ApiRequestOptions): string => {
62
+ const encoder = config.ENCODE_PATH || encodeURI;
63
+
64
+ const path = options.url
65
+ .replace('{api-version}', config.VERSION)
66
+ .replace(/{(.*?)}/g, (substring: string, group: string) => {
67
+ if (options.path?.hasOwnProperty(group)) {
68
+ return encoder(String(options.path[group]));
69
+ }
70
+ return substring;
71
+ });
72
+
73
+ const url = `${config.BASE}${path}`;
74
+
75
+ return url;
76
+ };
77
+
64
78
65
79
/**
66
80
* Request method
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ export const sendRequest = async <T>(
15
15
headers,
16
16
data: body ?? formData,
17
17
method: options.method,
18
+ params: options.query,
18
19
withCredentials: config.WITH_CREDENTIALS,
19
20
withXSRFToken: config.CREDENTIALS === 'include' ? config.WITH_CREDENTIALS : false,
20
21
cancelToken: source.token,
You can’t perform that action at this time.
0 commit comments