Use a file path with a user-specified separator to grab a value from a nested object.
npm install value-from-nested-obj
import valueFromNestedObj from 'value-from-nested-obj';
const objToTraverse = {
my: {
nested: {
path: 'my nested value'
}
}
}
// First param is the nested path, the second is the path separator, and the third is the js object
const value = valueFromNestedObj('my.nested.path', '.', objToTraverse);