prefer async/await over then

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>

Co-authored-by: John Molakvoæ <skjnldsv@users.noreply.github.com>
This commit is contained in:
blizzz 2021-04-06 19:05:48 +02:00 committed by Arthur Schiwon
parent ca81e958a5
commit a2a40c753d
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
1 changed files with 12 additions and 16 deletions

View File

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