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
This commit is contained in:
Aminejv 2021-09-22 12:09:49 +01:00
parent 95900d3e1e
commit 2220ba8941

View File

@ -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,
});
};