Skip to content

Commit

Permalink
🐛 Fix typo in function name #141
Browse files Browse the repository at this point in the history
  • Loading branch information
elbywan committed Sep 3, 2022
1 parent 7c5b224 commit d82cfd5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ wretch().middlewares([
until: (response, error) => response && response.ok,
onRetry: null,
retryOnNetworkError: false,
resolveWithLatestReponse: false
resolveWithLatestResponse: false
})
])./* ... */

Expand Down
10 changes: 5 additions & 5 deletions src/middlewares/retry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export type RetryOptions = {
*
* _Default: `false`_
*/
resolveWithLatestReponse?: boolean
resolveWithLatestResponse?: boolean
}

/**
Expand All @@ -74,7 +74,7 @@ export type RetryOptions = {
* until: (response, error) => response && response.ok,
* onRetry: null,
* retryOnNetworkError: false,
* resolveWithLatestReponse: false
* resolveWithLatestResponse: false
* })
* ])
*
Expand Down Expand Up @@ -105,7 +105,7 @@ export const retry: RetryMiddleware = ({
until = defaultUntil,
onRetry = null,
retryOnNetworkError = false,
resolveWithLatestReponse = false
resolveWithLatestResponse = false
} = {}) => {

return next => (url, opts) => {
Expand Down Expand Up @@ -141,11 +141,11 @@ export const retry: RetryMiddleware = ({
return checkStatus(null, error)
})
} else {
return resolveWithLatestReponse ? response : Promise.reject(error || new Error("Number of attempts exceeded."))
return resolveWithLatestResponse ? response : Promise.reject(error || new Error("Number of attempts exceeded."))
}
}

return resolveWithLatestReponse ? response : error ? Promise.reject(error) : response
return resolveWithLatestResponse ? response : error ? Promise.reject(error) : response
})
}

Expand Down
4 changes: 2 additions & 2 deletions test/node/middlewares/retry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ export default describe("Retry Middleware", () => {
expect(counter).toBe(10)
})

it("should pass the latest response instead of throwing an error if resolveWithLatestReponse is true", async () => {
const w = base().middlewares([retry({ delayTimer: 1, resolveWithLatestReponse: true })], true)
it("should pass the latest response instead of throwing an error if resolveWithLatestResponse is true", async () => {
const w = base().middlewares([retry({ delayTimer: 1, resolveWithLatestResponse: true })], true)
// WretchError
await expect(w.get("/retry").res()).rejects.toMatchObject({ response: { ok: false, counter: 12 } })
})
Expand Down

0 comments on commit d82cfd5

Please sign in to comment.