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

subscribe() and unsubscribe() is undefined when using this.$pusher in Nuxt.js #8

Open
fahmiegerton opened this issue Feb 6, 2021 · 0 comments

Comments

@fahmiegerton
Copy link

This function, subscribe() and unsubscribe() is undefined when using this.$pusher in Nuxt.js. I already set the mode to client, follow the instruction, but nothing work. Here's the plugin vue-pusher.js fiile I made.

import Vue from "vue";
// import VuePusher from "vue-pusher";

export default ({$config: {pusherKey, pusherCluster}}) => {
   Vue.use(VuePusher, {api_key: pusherKey, options: {cluster: pusherCluster, encrypted: false}})
}

And using it in the pages like this:

export default {
    ......
    mounted() {
        this.pusher()
    },
   methods: {
        pusher() {
            var channel = this.$pusher.subscribe('railway')
            channel.bind('01', (data) => {
                    // do with the data
            })
        },
      .......
   },
  .....
}

Any idea what is wrong with this conifiguration? thank you

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

No branches or pull requests

1 participant