Skip to content

Commit

Permalink
perf: axios reject handle
Browse files Browse the repository at this point in the history
  • Loading branch information
dongnaebi committed Feb 14, 2023
1 parent 81e4e3a commit 86d12ed
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/axues/src/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,20 @@ export function createAxues (axiosInstance: AxiosInstance, createOptions?: Creat
headers: mergeHeaders(baseConfig?.headers, config.headers, config.contentType)
}
return new Promise((resolve, reject) => {
axiosInstance(axiosConfig)
.then(response => {
axiosInstance(axiosConfig).then(
response => {
const res = responseHandle?.(response) || response.data
if (res instanceof Error) {
reject(res)
} else {
resolve(res)
}
})
.catch(err => {
},
err => {
const handledErr = errorHandle?.(err) || err
reject(handledErr)
})
}
)
})
}
function addAlias (method: string) {
Expand Down

0 comments on commit 86d12ed

Please sign in to comment.