mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-23 01:50:13 +08:00
fix(api): replace Axios constructor with axios.create for better defaults
Using axios.create() provides better default configuration and error handling compared to the Axios constructor
This commit is contained in:
parent
7632efda88
commit
e4f0743e2f
@ -15,7 +15,7 @@ import {
|
|||||||
UpdateAgentResponse,
|
UpdateAgentResponse,
|
||||||
UpdateAgentResponseSchema
|
UpdateAgentResponseSchema
|
||||||
} from '@types'
|
} from '@types'
|
||||||
import { Axios, AxiosRequestConfig, isAxiosError } from 'axios'
|
import axios, { Axios, AxiosRequestConfig, isAxiosError } from 'axios'
|
||||||
import { ZodError } from 'zod'
|
import { ZodError } from 'zod'
|
||||||
|
|
||||||
type ApiVersion = 'v1'
|
type ApiVersion = 'v1'
|
||||||
@ -46,7 +46,7 @@ export class AgentApiClient {
|
|||||||
if (config.baseURL.endsWith('/')) {
|
if (config.baseURL.endsWith('/')) {
|
||||||
throw new Error('baseURL should not end with /')
|
throw new Error('baseURL should not end with /')
|
||||||
}
|
}
|
||||||
this.axios = new Axios(config)
|
this.axios = axios.create(config)
|
||||||
if (apiVersion) {
|
if (apiVersion) {
|
||||||
this.apiVersion = apiVersion
|
this.apiVersion = apiVersion
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user