-
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: 2 comments 2 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.
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
, asfetch
unfortunately does not track progress - you'd have to useaxios
or one manual XHRRequest.