{ // Extract person data from the request body const { name, age, gender } = req.body; // Create a new person document using the Person model const person = new Person({ name, age, gender }); // Save the person to the database await person.save(); res.status(201).json({ message: 'Person saved successfully' }); } catch (error) { console.error('Error saving person:', error); res.status(500).json({ error: 'Error saving person' }); } });