Skip to content

Commit

Permalink
ref: replace axios with Nova.request()
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafaznv committed Dec 18, 2023
1 parent ba0ae33 commit 307baee
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
19 changes: 10 additions & 9 deletions resources/js/components/media-browser/MediaBrowserUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
<script setup>
import {ref, computed, watch} from "vue"
import Modal from "../modal.vue"
import axios from "axios"
import {useLocalization} from 'laravel-nova'
import MediaBrowserUploadProgress from "./MediaBrowserUploadProgress.vue"
import MediaBrowserUploadWithCover from "./MediaBrowserUploadWithCover.vue"
Expand Down Expand Up @@ -250,15 +249,17 @@ async function upload(file, index) {
data.append(uploadFileKey.value, file)
try {
await axios.post(
uploadApiUrl.value, data,
{
onUploadProgress: (e) => {
calculateItemUploadedPercent(e, index)
calculateTotalUploadedPercent()
await Nova.request()
.post(
uploadApiUrl.value,
data,
{
onUploadProgress: (e) => {
calculateItemUploadedPercent(e, index)
calculateTotalUploadedPercent()
}
}
}
)
)
return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import {ref, watch, computed} from "vue"
import {useLocalization} from 'laravel-nova'
import FileInput from "../FileInput.vue"
import axios from "axios"
// exposes
Expand Down Expand Up @@ -110,14 +109,16 @@ async function upload() {
data.append('file[cover]', file.value.cover)
try {
await axios.post(
props.uploadApiUrl, data,
{
onUploadProgress: (e) => {
percent.value = Math.round((e.loaded * 100) / e.total)
await Nova.request()
.post(
props.uploadApiUrl,
data,
{
onUploadProgress: (e) => {
percent.value = Math.round((e.loaded * 100) / e.total)
}
}
}
)
)
Nova.success(__('Uploading process has been completed.'))
result = true
Expand Down

0 comments on commit 307baee

Please sign in to comment.