I think you need to rethink how you're structuring this access list. The semantics you're using don't fit together with what it is you're trying to accomplish.
[ A, B, C ]
defines an array, which means it can contain elements but you
cannot specify the
A: B
relationship. It's not designed for that.
{ A: B, C: D }
defines an object, which means you can define the
A: B
relationship, and arrays must be included as a child property.
From your example you probably need to choose whether you want one of the following:
const accessList = {
"Admin": [ "/api/..", "/api/.." ],
"Data Entry Operator": [ "/api/..", "/api/.." ]
}
const endpoints = accessList.Admin;
const endpoints = accessList["Data Entry Operator"];
const accessList = [
{ "Name": "Admin", "Endpoints": [ "/api/.." ] },
{ "Name": "Data Entry Operator", "Endpoints": [ "/api/.."] }
]
const admin = accessList.filter(x => x.Name == "Admin")[0];
const endpoints = admin.Endpoints;