From a2a40c753d8b5e3eebb69ba754f7316aa0edc7ec Mon Sep 17 00:00:00 2001 From: blizzz Date: Tue, 6 Apr 2021 19:05:48 +0200 Subject: [PATCH] prefer async/await over then MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Arthur Schiwon Co-authored-by: John Molakvoæ --- apps/files/src/services/Download.js | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/apps/files/src/services/Download.js b/apps/files/src/services/Download.js index 83238c7fcd..b18ec3a17e 100644 --- a/apps/files/src/services/Download.js +++ b/apps/files/src/services/Download.js @@ -23,21 +23,17 @@ import { generateUrl } from '@nextcloud/router' import axios from '@nextcloud/axios' -export default function(files, dir, downloadStartSecret) { - axios.post( - generateUrl('apps/files/registerDownload'), - { - files, - dir, - downloadStartSecret, - } - ).then(res => { - if (res.status === 200 && res.data.token) { - const dlUrl = generateUrl( - 'apps/files/ajax/download.php?token={token}', - { token: res.data.token } - ) - OC.redirect(dlUrl) - } +export default async function(files, dir, downloadStartSecret) { + const res = await axios.post(generateUrl('apps/files/registerDownload'), { + files, + dir, + downloadStartSecret, }) + + if (res.status === 200 && res.data.token) { + const dlUrl = generateUrl('apps/files/ajax/download.php?token={token}', { + token: res.data.token, + }) + OC.redirect(dlUrl) + } }