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:
icarus 2025-09-18 20:47:53 +08:00
parent 7632efda88
commit e4f0743e2f

View File

@ -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
} }