-
| Hi, is there an efficient way of tracking upload progress with RTK Query, like for example Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
| Writing such a baseQuery wouldn't really help you, as RTK Query itself only tracks start and end, no progress. My recommendation would be to handle such an upload independently from RTK Query - or maybe in a |
Beta Was this translation helpful? Give feedback.
-
| @phryneas Thanks for the works you guys put into this amazing library. type CallbackFunc = ( progress: Record<string, { progress?: number; url?: string }> ) => void; createProduct: build.mutation< unknown, { product: IProduct; onImageUploadProgress: CallbackFunc; } >({ async queryFn(arg) { const { images, ...products } = arg.product; await uploadImage( images, arg.onImageUploadProgress); await setDoc(productsDocRef, products); return { data: {} }; }, invalidatesTags: ["products"], }) |
Beta Was this translation helpful? Give feedback.
-
| A utility package for integrating file upload/download with progress tracking into your Redux Toolkit Query API slices: |
Beta Was this translation helpful? Give feedback.
Writing such a baseQuery wouldn't really help you, as RTK Query itself only tracks start and end, no progress.
My recommendation would be to handle such an upload independently from RTK Query - or maybe in a
queryFn. There you won't be able to usefetch, asfetchunfortunately does not track progress - you'd have to useaxiosor one manual XHRRequest.