I have an express route that looks like this:
app.get('/api/v1/username/:option', function(req, res) {
// do stuff
})
How can I modify this route so that the URL show the parameter name of option (option=)? For example:
http://localhost:8080/api/v1/johndoe/option=my-cool-option
That's a URL segment, not a parameter.
If you want it like you've shown the URL, it'd be
http://localhost:8080/api/v1/johndoe/?option=my-cool-option
Note the question mark ?, this specifies that it's a GET parameter.
app.get('/api/v1/:username', function(req, res) {
//req.params.username would equal 'johndoe'
//req.query.option would equal 'my-cool-option'
})