import a function multiple times with different params

Viewed 34

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?

0 Answers
Related