1
I need to create a route that changes the project title with the id present in the route parameters. But when testing the route I get error 500(Typeerror: Cannot set Property 'title' of Undefined)
Here is my code:
const server = express();
server.use(express.json());
const projects = [];
server.put('/projects/:id', (req, res) => {
const { id } = req.params;
const { title } = req.body;
const project = projects.find(p => p.id == id);
project.title = title;
return res.json(project);
});