-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a test of retrying via the demo
- Loading branch information
Showing
4 changed files
with
73 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<!-- Test of axios retrying --> | ||
|
||
<template lang='pug'> | ||
|
||
.axios-retry-test | ||
| Tried <strong>{{type}}</strong> | ||
| with <strong>{{ code }}</strong> response | ||
| <strong>{{ tries }} time(s)</strong> | ||
|
||
</template> | ||
|
||
<!-- ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– --> | ||
|
||
<script lang='coffee'> | ||
import MockAdapter from 'axios-mock-adapter' | ||
export default | ||
props: | ||
type: String | ||
code: Number | ||
data: -> tries: 0 | ||
# Run query using mounted instead of fetch so that the tries count updates | ||
mounted: -> | ||
# Make a clean client to mock | ||
client = @$addAxiosRetry @$axios.create() | ||
# Mock response using passed in code | ||
mock = new MockAdapter client | ||
mock.onAny().reply (config) => | ||
@tries++ | ||
return [@code, {}] | ||
# Trigger request and ignore erros | ||
try await client.post '/example', query: switch @type | ||
when 'query' then '{ id }' | ||
when 'mutation' then 'mutation update() { id }' | ||
catch e | ||
</script> | ||
|
||
<!-- ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– --> | ||
|
||
<style lang='stylus' scoped> | ||
.axios-retry-test | ||
border 1px solid currentColor | ||
padding 1em | ||
display inline-block | ||
margin-bottom 0.3em | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
# [@cloak-app/boilerplate](https://github.com/BKWLD/cloak-boilerplate) | ||
|
||
## Heya World | ||
## Axios Retrying | ||
|
||
Maecenas faucibus mollis interdum. Donec sed odio dui. Sed posuere consectetur est at lobortis. Etiam porta sem malesuada magna mollis euismod. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. | ||
This component mocks the injected Axios method and simulates a requests, counting the number of attempts made. Only the failed query should be retried multiple times. | ||
|
||
<axios-retry-test type='query' :code='200'></axios-retry-test> | ||
<axios-retry-test type='query' :code='500'></axios-retry-test> | ||
<axios-retry-test type='mutation' :code='200'></axios-retry-test> | ||
<axios-retry-test type='mutation' :code='500'></axios-retry-test> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters