I'm getting a request in the following form:
req = {
"id": ["1","2"],
"values": ["fruit", "vegies"]
}
I want to send response as the following:
res = {
"idMap": {
"1": ["fruit", "veggies"],
"2": ["fruit", "veggies"]
}
}
I tried using map function but values comes as [Array] and not as ["fruits", "veggies"]. I attach the code below:
const values = req.values
const id = req.id.map((ids) => {
const idmap = {
[ids]: values
}
return idmap;
});
req = {
"idMap": id
}
help me with this guys. Thanks in advance..
reshave the same object reference of the arrays?