Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useUpload - ReferenceError: global is not defined #275

Closed
aligzl opened this issue Sep 12, 2024 · 2 comments · Fixed by #278
Closed

useUpload - ReferenceError: global is not defined #275

aligzl opened this issue Sep 12, 2024 · 2 comments · Fixed by #278

Comments

@aligzl
Copy link

aligzl commented Sep 12, 2024

Describe the bug
Hi I am using Blob to upload images and have simple method as below and getting error.

const upload = useUpload('/api/blob', { method: 'PUT' })

async function onFileChange(e: Event) {
  try {
    const input = e.target as HTMLInputElement

    if (!input.files?.length) {
      return
    }

    const uploadedFiles = await upload(input as HTMLInputElement)

    console.log(uploadedFiles);

    state.value.avatar = URL.createObjectURL(input.files[0])
  } catch (error) {
    console.log(error)
    useNotifier({
      message: error?.data ?? error
    })
    
  }
}

ReferenceError: global is not defined
at upload (useUpload.js?v=f063f999:12:5)
at onFileChange (form.vue:88:33)
at callWithErrorHandling (runtime-core.esm-bundler.js?v=f063f999:197:19)
at callWithAsyncErrorHandling (runtime-core.esm-bundler.js?v=f063f999:204:17)
at HTMLInputElement.invoker (runtime-dom.esm-bundler.js?v=f063f999:713:5)

my package.json file

{
  "name": "nuxt-ui-pro-template-dashboard",
  "private": true,
  "type": "module",
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare",
    "lint": "eslint .",
    "typecheck": "nuxt typecheck"
  },
  "dependencies": {
    "@iconify-json/heroicons": "^1.2.0",
    "@iconify-json/simple-icons": "^1.2.2",
    "@nuxt/fonts": "^0.8.0",
    "@nuxt/ui-pro": "^1.4.2",
    "@nuxthub/core": "^0.7.12",
    "@pinia/nuxt": "^0.5.4",
    "@vueuse/nuxt": "^11.0.3",
    "date-fns": "^3.6.0",
    "maska": "^3.0.2",
    "nuxt": "^3.13.1",
    "nuxt-security": "^2.0.0-rc.9",
    "pinia": "^2.2.2",
    "v-calendar": "^3.1.2",
    "vue-router": "^4.4.4",
    "yup": "^1.4.0"
  },
  "devDependencies": {
    
    "@nuxtjs/i18n": "^8.5.3",
    "@nuxt/eslint": "^0.5.6",
    "eslint": "^9.10.0",
    "vue-tsc": "^2.1.6",
    "wrangler": "^3.76.0"
  }
}

Steps to reproduce
Same steps as explained in the nuxt-hub docs

Expected behavior

@atinux
Copy link
Contributor

atinux commented Sep 12, 2024

This is a known issue we have with latest Nuxt, not related to useUpload, please see #261 (comment)

@atinux
Copy link
Contributor

atinux commented Sep 12, 2024

I'm sorry about this, I released a patch in v0.7.14!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants