[SOLVED] Alternative for this.$router.push('/'); .. how to solve it without using vue-router


#1

methods: {
signIn(){

		axios({
		  method: 'post',
		  url: 'http://localhost:9000/auth/login',
		  data: this.login,
		}).then(function (response) {
		    console.log(response.data.token);
		    this.$router.push('/'); // it is not available here in framework7vue.. what would be alternative for it
		
		 });
	}
}

Why doesn't my $f7route have a context?
#2

this inside axios is not pointing to vue instance. declare a vm before the axios call and then use it.
eg

let vm = this // now VM is your vue instance 
		axios({
		  method: 'post',
		  url: 'http://localhost:9000/auth/login',
		  data: this.login,
		}).then(function (response) {
		    console.log(response.data.token);
		    vm .$router.push('/'); // it is not available here in framework7vue.. what would be alternative for it
		
		 });
	}
}

#4

Thank you so much for you response


#5

Alternative would be:

this.$f7router.navigate('/');