nuxt / nuxt

The Intuitive Vue Framework.

Home Page:https://nuxt.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

onUploadProgress on $fetch

a7med-hussien opened this issue · comments

Environment


  • Operating System: Windows_NT
  • Node Version: v20.12.2
  • Nuxt Version: 3.11.2
  • CLI Version: 3.11.1
  • Nitro Version: 2.9.6
  • Package Manager: npm@10.1.0
  • Builder: -
  • User Config: app, routeRules, runtimeConfig, css, colorMode, googleFonts, ssr, devtools, ignore, modules, build, dayjs, auth
  • Runtime Modules: @nuxt/ui@2.15.2, @vueuse/nuxt@10.9.0, @nuxt/image@1.6.0, @pinia/nuxt@0.5.1, @sidebase/nuxt-auth@0.6.7, @pinia-plugin-persistedstate/nuxt@1.2.0, @nuxtjs/device@3.1.1, @nuxtjs/google-fonts@3.2.0, dayjs-nuxt@2.1.9, @nuxtjs/fontaine@0.4.1, @formkit/auto-animate/nuxt@0.8.2, @nuxt/test-utils/module@3.12.1, floating-vue/nuxt, @samk-dev/nuxt-vcalendar@1.0.3
  • Build Modules: -

Reproduction

upload(files) {
  const config = {
    onUploadProgress: function(progressEvent) {
      const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total)
      console.log(percentCompleted)
    }
  }

  let data = new FormData()
  data.append('file', files[0])

  $fetch(url, {
    method: 'POST',
    body: data,
    config
  }).then(res => console.log({ res })).catch(err => console.log({ err }))}

Describe the bug

i can't find onUploadProgress in $fetch module
we used to use it in axios to enable us making a progress bar while uploading images

Additional context

No response

Logs

No response

unjs/ofetch#45

It's not support now...

Closing in favor of unjs/ofetch#45. Should work in chrome only at the moment with a bit of hand work.