T
TanStack2y ago
extended-salmon

Error Handling Mechanism

Hi, i have a question regarding the error handling mechanism For the query function I provide the following arrow function: () => axios.get('url').then(res => return res.data) Why does react query know about the error that axios has if something went wrong? I’m returning the data and not the promise where ‘.catch()’ could be used by react query. Could you help me to understand how this works?
3 Replies
deep-jade
deep-jade2y ago
resolved promise === data rejected promise === error
extended-salmon
extended-salmonOP2y ago
Ok, but i do not provide a promsise. I only give the data with a resolved promise. Or is it implicite a promise because i do not return something outside ".then"?
deep-jade
deep-jade2y ago
the code you showed returns a Promise. that's how .then works

Did you find this page helpful?