flyingduck92
flyingduck92

Reputation: 1644

VueJS - variable is defined but never used (Sending Data to Firebase)

I have an issue when learning VueJS. I want to send data to Firebase, but it keeps telling me that the variables never used. I declare it inside a promise.

This is the script:

methods: {
        register: function() {
          const info = {
            email: this.email,
            password: this.passOne,
            displayName: this.displayName
          };

          if(!this.error) {
              Firebase.auth()
              .createUserWithEmailAndPassword(info.email, info.password)
              .then( 
                userCredentials => {
                  this.$router.replace('meetings');
                },
                error => {
                  this.error = error.message;
                }
              );
          }
        }
    },

This is the error:

error    'userCredentials' is defined but never used  no-unused-vars

Upvotes: 3

Views: 1364

Answers (2)

Mahamudul Hasan
Mahamudul Hasan

Reputation: 2823

replace your $router.replace(...) code like below

this.$router.replace({ name: 'meetings', params: { credentials: userCredentials } })

hope it will solve your issue.

Upvotes: 0

Raffobaffo
Raffobaffo

Reputation: 2856

Thats an es-lint error. To solve:

            if(!this.error) {
              Firebase.auth()
               .createUserWithEmailAndPassword(info.email, info.password)
              .then( 
                 () => {
                    this.$router.replace('meetings');
               },

or you can also ask es-lint to do not look for the next line:

           //es-lint-disable-next-line no-unused-vars
           .then( userCredentials => {
              this.$router.replace('meetings');
            },

Upvotes: 2

Related Questions