axios config

Signed-off-by: Jakob Röhrl <jakob.roehrl@web.de>
This commit is contained in:
Jakob Röhrl
2020-04-01 11:11:28 +02:00
committed by Julius Härtl
parent 2eca9c2d01
commit 6cab67cb11
2 changed files with 15 additions and 2 deletions

View File

@@ -39,7 +39,11 @@ export default {
bodyFormData.append('type', 'deck_file')
bodyFormData.append('file', file)
try {
await this.$store.dispatch('createAttachment', { cardId: this.cardId, formData: bodyFormData })
await this.$store.dispatch('createAttachment', { cardId: this.cardId,
formData: bodyFormData,
onUploadProgress: (e) => {
console.log(e)
} })
} catch (err) {
if (err.response.data.status === 409) {
this.overwriteAttachment = err.response.data.data

View File

@@ -37,11 +37,20 @@ export class AttachmentApi {
return response.data
}
async createAttachment({ cardId, formData }) {
async createAttachment({ cardId, formData, onUploadProgress }) {
const config = {
onUploadProgress: function(progressEvent) {
const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total)
console.log(percentCompleted)
},
}
const response = await axios({
method: 'POST',
url: this.url(`/cards/${cardId}/attachment`),
data: formData,
...config,
onUploadProgress,
})
return response.data
}