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 ead027b commit ced311cCopy full SHA for ced311c
src/guide/reusability/composables.md
@@ -216,15 +216,16 @@ export function useFetch(url) {
216
const data = ref(null)
217
const error = ref(null)
218
219
- watchEffect(() => {
220
- // reset state before fetching..
221
- data.value = null
222
- error.value = null
223
- // toValue() unwraps potential refs or getters
224
- fetch(toValue(url))
+ const fetchData = (dt) => {
+ fetch(toValue(url))
225
.then((res) => res.json())
226
.then((json) => (data.value = json))
227
.catch((err) => (error.value = err))
+ }
+
+ watchEffect(() => {
+ // reset state before fetching..
228
+ fetchData(url)
229
})
230
231
return { data, error }
0 commit comments