Kushagra Agarwal
Kushagra Agarwal

Reputation: 1725

how to pass multiple parameters in url when using vuejs

Hey i am trying to pass two parameters in my url for a simple spa and the params values will be extracted from the url using an api and passed to the server here is the url:

http://localhost:8080/#/game/username/token

but when i am hitting the url its passing this in the network:

Request URL:http://localhost:8080/api/game/usernametoken

and hence it is not hitting the right api

router:

    {path:'game/:name/:token', name:'game', component: game  }

front end:

this.$http.get('/api/game/'+this.$route.params.name+this.$route.params.token)

server-side:

app.get('/api/game/:name/:token',function(req,res,err){
      var tex = {push:false};
    console.log("diplaying token from the server"+req.params.name+req.params.token)
    res.end(JSON.stringify(tex));

})

Upvotes: 5

Views: 16703

Answers (1)

Vamsi Krishna
Vamsi Krishna

Reputation: 31362

Your get request should be

this.$http.get('/api/game/'+this.$route.params.name + '/' + this.$route.params.token)

You forgot the '/'

Upvotes: 4

Related Questions