add timeout feature
tasiotas opened this issue · 1 comments
tasiotas commented
Your use case
Hi,
I am not sure if its currently possible to handle long requests by specifying timeout and catching it.
useFetch/$fetch/ofetch does support it very nicely.
await $fetch('https://httpbin.org/delay/10', {
timeout: 1000,
}).catch(() => {
console.log('timeout')
})
The solution you'd like
I would like to specify timeout per composable and define global default in config
await useAsyncGql({
operation: 'product',
variables: { slug },
options: {
timeout: 1000,
},
}).catch(() => {
console.log('error')
})
Possible alternatives
Not aware of any. Adding timeout to options of useAsyncGql doesnt work
Additional information
No response
toknT commented
find a timeout feature too, I set a timeout function globally in flutter's graphql client .In this library current I do like this
showLoading();
GqlLogin({ username: form.username, password: form.password }).then((data) => {
// your code after login success
}).catch((error) => {
setTimeout(() => {
closeLoading();
if (error.gqlErrors[0].message) {
showErrorToast(error.gqlErrors[0].message);
} else {
showErrorToast('network error');
}
}, 300)
});
Because I can get gqlErrors from my server , if not it maybe timeout. lol