Is it possible to use variable variables in JS so that a JSON config file can be used to set the required object name and be accessed by a function?
take the following POST express code
//form passed to express has a field
req.body = {"myFieldA":"hello","myFieldB":"world"}
// store that as a reference in a JSON config file
config.js
{
myFields:{
alpha:"req.body.myFieldA",
beta: "req.body.myFieldB"
}
}
//in server.js access the object by the JSON reference
import config from './config.js';
myVal = config.myFields.alpha;
// myval should now = "hello"