From 2220ba8941a7c953ddfb7a8597aa694d31f8ac04 Mon Sep 17 00:00:00 2001 From: Aminejv Date: Wed, 22 Sep 2021 12:09:49 +0100 Subject: [PATCH] feat(actions/createLink): - returnJSON will return {aborted: true} as a response when the fetch is aborted - pass options argument to extend createLink's request options --- common/actions.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/actions.js b/common/actions.js index 0716e338..3f039977 100644 --- a/common/actions.js +++ b/common/actions.js @@ -44,6 +44,7 @@ const returnJSON = async (route, options) => { return json; } catch (e) { + if (e.name === "AbortError") return { aborted: true }; Logging.error(e); } }; @@ -223,11 +224,12 @@ export const createFile = async (data) => { }); }; -export const createLink = async (data) => { +export const createLink = async (data, options) => { await Websockets.checkWebsocket(); return await returnJSON(`/api/data/create-link`, { ...DEFAULT_OPTIONS, body: JSON.stringify({ data }), + ...options, }); };