From f0e3c6f3d5b7563eaf3e8cce43e2cfb2998a53fa Mon Sep 17 00:00:00 2001 From: Andrey Dolgolev Date: Mon, 29 Nov 2021 13:15:41 +0200 Subject: [PATCH] Replace requestNewURLCallback to refetch. --- frontend/src/core/hooks/usePresignedURL.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/src/core/hooks/usePresignedURL.js b/frontend/src/core/hooks/usePresignedURL.js index 3ad10758..8edb340a 100644 --- a/frontend/src/core/hooks/usePresignedURL.js +++ b/frontend/src/core/hooks/usePresignedURL.js @@ -19,7 +19,7 @@ const usePresignedURL = ({ // You can uncomment this to use mockupsLibrary in development // url: `https://example.com/s3`, method: "GET", - timeout: 15 * 1000, + timeout: 15 * 1000, // response await timeout }); return response.data; }; @@ -33,10 +33,12 @@ const usePresignedURL = ({ onError: (e) => { if ( e?.response?.data?.includes("Request has expired") || - e?.response?.status === 403 || - e.code === "ECONNABORTED" + e?.response?.status === 403 ) { requestNewURLCallback(); + } else if (e.code === "ECONNABORTED") { + // Called when the response timeout expires + refetch(); } else { toast(error, "error"); }