Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jeans's avatar
Level 1

this.$router.push() inside common service file

Hey,

I have created a common service file. Where I have a custom function which returns this.$router.push(route) but that file is imported to another file. I am able to access all functions except redirect it through the error on push().

So, let me know how I can make a common function for redirecting to a particular route by giving in parameters and using all pages.

import router from '../routes.js';
	redirect(route){
		return this.$router.push(route)
	}
0 likes
0 replies

Please or to participate in this conversation.