We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ced311c commit e0a3792Copy full SHA for e0a3792
src/guide/reusability/composables.md
@@ -216,15 +216,18 @@ export function useFetch(url) {
216
const data = ref(null)
217
const error = ref(null)
218
219
- const fetchData = (dt) => {
220
- fetch(toValue(url))
+ const fetchData = (dt) => {
+ // reset state before fetching..
221
+ data.value = null
222
+ error.value = null
223
+
224
+ fetch(toValue(dt))
225
.then((res) => res.json())
226
.then((json) => (data.value = json))
227
.catch((err) => (error.value = err))
- }
228
+ }
229
230
watchEffect(() => {
- // reset state before fetching..
231
fetchData(url)
232
})
233
0 commit comments