Type Error global.XMLHttpRequest is not a constructor in NUXT

927 Views Asked by At

I am trying to use THIS library on the client side as a plugin When I npm run dev the client, I get this error enter image description here

My vue2socketcluster.js file inside the plugins folder looks like this

import Vue2Socketcluster from 'vue2-socketcluster'

Vue.use(Vue2Socketcluster,{
  hostname:"localhost",

  secure:true,
  propName:"socket" // Defaults to socket - so if you want vm.$soc you would change this to "soc"
})

and nuxt config had an entry for plugins

plugins: [
  '~/plugins/vue2socketcluster'
],

Any direction will be super appreciated

1

There are 1 best solutions below

1
On

Fixed it by setting server side rendering to false. Thank you

plugins: [
  { src: '~/plugins/sc', mode: 'client' }
],