Hi I am trying create a new array from an exisiting array in React, but I need to cut down on the information in the array.
Currently the raw json data looks like this:
[{"id":"1",
"first":"'Norm'",
"last":"'Macdonald'",
"student_id":"78",
"email":"Hello@gmail.com",
"phone":"3603603600",
"address":"782 st",
"postbaccalaureate":"No",
"withdrawing":"No",
"veterans_benefits":"No",
"active":"Yes",
"non_stem_majors":"None"}
I use Axios to create an array in React. Then I need to create another array that will look like this:
[
{
label: first + last + student_id,
value: id
}
]
for every element in the above array. I am currently using map, but it is not working. Here is my current idea that is not working:
useEffect(() => {
const temp = students.map((student) => {
{label: student.first + ", " + student.last + " " + student.student_id, value: student.id}
})
Any help would be appreciated.