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

165
Views
import a function multiple times with different params

I have the following function on file_a.js:

export fetchData = (active = true) => {
  if (active) { 
    // fetch active data from API
  else {
    // fetch expired data
  }
}

And I'm trying to use it like this:

import { fetchData } from 'file_a.js'
...

const activeData = fetchData(true);
const expiredData = fetchdata(false);

But whenever I do this, both consts end up with the same data. How can I use the same imported method to get two different sets of data?

about 4 years ago · Juan Pablo Isaza
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!