Example: http://localhost:8080/watch/abcxyz-145#es-2
I want to get slug after '#'. I try get below code but not.
app.get('/watch/:slug', function(req, res, next) {
var slug = req.params.slug;
var slugs = slug.split(/[\s-]+/);
}
Example: http://localhost:8080/watch/abcxyz-145#es-2
I want to get slug after '#'. I try get below code but not.
app.get('/watch/:slug', function(req, res, next) {
var slug = req.params.slug;
var slugs = slug.split(/[\s-]+/);
}
Short answer - You can't.
At least not on the server side. The browser doesn't actually send the string after # to the server. If you need to get that information from the browser to your Node.js/Express server, I would recommend grabbing it via window.location.hash
, then using query params or including it in your request some other way. Assuming you have access to code on the client side.
Check out this answer for additional information
If you can't go that route, (no pun intended) you can check out this answer for a work around, but again, don't make this harder than it needs to be if it's just a matter of sending the rest of a slug to the server.