[Vuejs]-VueRouter make HTTP request within beforeEach

2👍

It should be

axios.get('/api/participant/test/' + to.params.id)

(with forward slash character at the beginner).

The more properly way to set baseURL in axios config

For example:

axios.defaults.baseURL = 'your base url';
👤ittus

1👍

First, there is no built-in getPost method in Vue.js. Documentation has mentioned it just as an illustration purpose.

Also, use root relative URL instead of relative URL that you are trying to use.

axios.get('/api/participant/test/' + to.params.id)

You are trying to use relative URL which is causing a problem for you. The more generic way would be to set default base URL in Axios global config.

Leave a comment