I have a configuration object that I need to use in multiple files
const config = {test: true}
can I import the JSON and assign it directly to a variable or I need to create a new file and export a function that returns the object?
I have a configuration object that I need to use in multiple files
const config = {test: true}
can I import the JSON and assign it directly to a variable or I need to create a new file and export a function that returns the object?
You can export it like this -
const config = { test: true }
export default config
and then you can simply import like this -
import config from "filePath"
Or you can include an actual JSON-File like this:
config.json
{"test": true}
app.js
const config = require('./config.json');
// Do your operations