Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

127
Views
How can I get the hexadecimal numbers from the base URL string

I am doing codes in node js express js But while working, I thought that if the hexadecimal number was taken from the base URL string, then my work would be easier.

I mean:

baseUrl: '/api/v1/movies/61b6e1c5503b122ff9436b14/seasons' (Get from req.baseUrl)

My base URL string is: '/api/v1/movies/61b6e1c5503b122ff9436b14/seasons'

I need just: 61b6e1c5503b122ff9436b14

I am currently using the javaScript replace() method but it does not seem to be very effective to me. I am especially interested to know any good method.

Thanks

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Regexp would be useful unless you are looking for dynamic routes

This would get the code

let baseUrl =  '/api/v1/movies/61b6e1c5503b122ff9436b14/seasons'
const hex = baseUrl.match(/movies\/(\w+)\/seasons/)[1]
console.log(hex.toUpperCase());

about 4 years ago · Juan Pablo Isaza Report

0

What you're looking for are called dynamic routes and in express you can do like this:

const express = require('express');
const app = express();

app.get('/api/v1/movies/:hexid/seasons', (req,res) => {

   console.log(req.params.hexid);

})

You can find more info in their docs ( search for :bookId )

about 4 years ago · Juan Pablo Isaza Report

0

You can use req.params to map the route parameters in ExpressJS

app.get('/api/v1/movies/:hashid/seasons', function (req, res) {
  console.log(req.params.hashid)
})
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!