I'm looking for a way to take an array of values, and generate an array of functions with the argument of said function being populated by each initial array item. For example...
const IDs = [001, 002, 003]
const getEmpData = (id) => { fetch(`companysite.com/data/user eq '${id}'`) }
// Code to generate below array
[
fetch(`companysite.com/data/user eq '001'`),
fetch(`companysite.com/data/user eq '002'`),
fetch(`companysite.com/data/user eq '003'`)
]
This is a very simplified version of a problem I'm trying to solve, which may not even be the ideal thing to do - but I was curious if this was an actual pattern. I would take the resulting array, chunk it, and then put it into a reduce method to make batches of API requests.
question from:
https://stackoverflow.com/questions/65849877/take-array-of-values-and-defined-function-and-generate-an-array-of-functions-wit 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…