From waiting list to a Car component

Hello,

I’m coming to you for a problem I can’t solve on React.

Here is a summary:

the picture

I have a waiting list with a passenger and a car list (left on the image). I would like that when a passenger clicks on a car, he is added to it. .

In the car there is a component, with buttons that add us to the car (right on the image).

I would like that when the person is added from the waiting list, it displays his name and records it at the same time in the car collection that has the passenger as a reference

Car collection
{ "_id" : ObjectId("5d53fecfd22cd872aa53c8c6"), "passengers" : [ ], "carName" : "Audi", "seats" : 2, "message" : "non", "contact" : "56562161", "email" : "aestoth@gmail.com", "address" : "chez cousine", "date" : "1920-02-22", "time" : "14:00", "__v" : 0 }

The buttons on the right use an API
app.post("/api/:id/passengersCar", async (req, res) => { let { id } = req.params; const newPassengers = PostModelPassengers(req.body); if (!req.body.name) { res.status(422).json({ errors: { message: "your name cannot be empty" } }); } console.log("newPassengers", newPassengers); const car = await PostModelCar.findById(id); // Get Car await newPassengers.save(); //Save the Passenger await car.passengers.push(newPassengers);

Thank you for your help.

Hi mate I read your code a couple of times to understand I am from angular but it should be the same…
I don’t understand what exactly is wrong ?