1

I got a problem on my express server

app.get('/callback/:nation/:username/?:permalink', function(req, res)
            {
                nationurl = req.params.nation;
                username = req.params.username;
                storypermalink = req.params.permalink;


                console.log("nation: "+nation);
                console.log("username: "+username);
                console.log("permalink: "+permalink);
            });

Beacause of the /?: it split the username and doesn't give my permalink :

nation: poneyclub
username: j
permalink: hondoe

Anybody have an idea ?

1
  • Could you please also post the URL with which you got this result. Commented Apr 4, 2012 at 11:15

1 Answer 1

6

This is because ? is a special character in Express routing algorithm. See the documentation for details.

When you type URL Express treats everything after ? character as a query. It should be in a format

?key1=value1&key2=value2&...&keyX=valueX

and it can be retrieved using req.query.

You can change this default behaviour using your own regular expression in route (again see the documentation for details).

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.