5

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));

})
2
  • show some code please... Commented Aug 28, 2017 at 8:31
  • sorry i am editing and adding code Commented Aug 28, 2017 at 8:33

1 Answer 1

4

Your get request should be

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

You forgot the '/'

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.