I want to get a value in my url.
My url is like :
host/:value.schema
I want to get value.
Exemple :
host/horse.schema value = horse
I have another route without .schema:
host/:value
Exemple :
host/horse value = horse
How tell Express to make the difference ?
You can try something like this:
app.get('/:value.:schema?', function (req, res) {
console.log(req.params);
});
You'll receive this:
http://localhost:3000/horse { value: 'horse', schema: undefined }
http://localhost:3000/horse.schema { value: 'horse', schema: 'schema' }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.