Skip to content

Commit

Permalink
feat: add function withResponse (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aybrea authored Apr 23, 2024
1 parent 9e68bd8 commit 7bd290b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/axle/src/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,18 @@ export function createFetchRunner(service: AxiosInstance, method: FetchMethod, r
}
}

export function withResponse<T>(pendingRes: Promise<T>): Promise<T> {
return new Promise<T>((resolve, reject) => {
pendingRes.then(resolve).catch((error) => {
if (error.response) {
resolve(error.response)
} else {
reject(error)
}
})
})
}

export function createModifyRunner(
service: AxiosInstance,
method: ModifyMethod,
Expand Down

0 comments on commit 7bd290b

Please sign in to comment.