I have an api call setup to retrieve some data I need when my express server starts and I want to reuse this data across multiple files by importing it. Basically making it a global, but only accessible via import/export.
UPDATE: I ONLY want to make the getCreds api call ONE time, since they will not change and then reference the creds throughout my app.
I'm not sure the best way to accomplish though. :/
file1.js, file2.js, etc...
import creds from './libs/creds.js'
...use creds for something...
libs/creds.js
// not sure how to set creds once and export it
let creds;
const getCreds = async () => {
...api call to get creds, but do not want to call repeatedly...
creds = api.data
}
export { creds };