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

182
Views
Display http param if value is not empty

Into React application I use this code to set value as url path param:

  const [exchangeId, setExchangeId] = useState('');

.....
    const endURL = `?page=${paginationState.activePage}&sort=${paginationState.sort},${paginationState.order}&exchangeId=${exchangeId}`;
.....

When I don't set with some value exchangeId I get always empty url param exchangeId=

Do you know how I can implement a check if exchangeId is not set to not include exchangeId= into http link?

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

0

You can use conditional (ternary) operators.

const exchangeId = '';
const paginationState = {
  activePage: 1,
  sort: 1,
  order: 1
}
const endURL = `?page=${paginationState.activePage}&sort=${paginationState.sort}&order=${paginationState.order}${exchangeId ? `&exchangeId=${exchangeId}` : ''}`;
console.log(endURL);

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!