Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
VCCI-News
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Văn Hoàng
VCCI-News
Commits
6875c0ff
Commit
6875c0ff
authored
Oct 31, 2025
by
Vũ Đình Nguyên
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update(gengenerate-api): update mutator custom clients
parent
6acd11e7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
5 deletions
+35
-5
custom-client.ts
src/api/mutator/custom-client.ts
+35
-5
No files found.
src/api/mutator/custom-client.ts
View file @
6875c0ff
...
...
@@ -27,13 +27,43 @@ AXIOS_INSTANCE.interceptors.response.use(
(error) => Promise.reject(error)
)
const useCustomClient = <T>(config: AxiosRequestConfig, options?: AxiosRequestConfig): Promise<T> => {
// Helper function to convert RequestInit headers to Axios format
const convertHeaders = (headers?: HeadersInit): Record<string, string> | undefined => {
if (!headers) return undefined
if (headers instanceof Headers) {
const result: Record<string, string> = {}
headers.forEach((value, key) => {
result[key] = value
})
return result
}
if (Array.isArray(headers)) {
const result: Record<string, string> = {}
headers.forEach(([key, value]) => {
result[key] = value
})
return result
}
return headers as Record<string, string>
}
const useCustomClient = <T>(url: string, options?: RequestInit): Promise<T> => {
const source = Axios.CancelToken.source()
const promise = AXIOS_INSTANCE({
...config,
...options,
// Convert RequestInit to AxiosRequestConfig
const axiosConfig: AxiosRequestConfig = {
url,
method: options?.method || 'GET',
headers: convertHeaders(options?.headers),
data: options?.body,
signal: options?.signal || undefined,
cancelToken: source.token
}).then(({ data, status }) => {
}
const promise = AXIOS_INSTANCE(axiosConfig).then(({ data, status }) => {
return data instanceof Blob ? data : { ...data, statusCode: status }
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment