Skip to content

Commit e0a3792

Browse files
committed
update
1 parent ced311c commit e0a3792

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/guide/reusability/composables.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,18 @@ export function useFetch(url) {
216216
const data = ref(null)
217217
const error = ref(null)
218218
219-
const fetchData = (dt) => {
220-
fetch(toValue(url))
219+
const fetchData = (dt) => {
220+
// reset state before fetching..
221+
data.value = null
222+
error.value = null
223+
224+
fetch(toValue(dt))
221225
.then((res) => res.json())
222226
.then((json) => (data.value = json))
223227
.catch((err) => (error.value = err))
224-
}
228+
}
225229
226230
watchEffect(() => {
227-
// reset state before fetching..
228231
fetchData(url)
229232
})
230233

0 commit comments

Comments
 (0)