I am learning React and came across a slightly tricky problem for my level. From my API call I get a response which is an array of objects. I want to submit data add some object data . To get the idea of how the response looks, this is an example (it is array of JSON) some data want to spread in array object data {school:"test",schoolId:"2"}
Response
data = [
{0: {name: "tom"}},
{1: {name: "Pope"}},
{2: {name: "jack"}}
];
Response to want send like
data = [
{
name: "tom",
school :"testing",
schoolId:"2"
},
{
name: "Pope",
school :"testing",
schoolId:"2"},
{
name: "jack",
school :"testing",
schoolId:"2"}
];
.mapon your data..data.map(item => ({...wrapper, item}))wherewrapper = { school: 'testing'. schoolOd: 2}