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 7d93d28 commit 620fe6cCopy full SHA for 620fe6c
src/guide/reusability/composables.md
@@ -216,16 +216,19 @@ 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 = () => {
+ // reset state before fetching..
221
+ data.value = null
222
+ error.value = null
223
+
224
+ fetch(toValue(url))
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..
- fetchData(url)
231
+ fetchData()
232
})
233
234
return { data, error }
0 commit comments