I’m trying to find clients by their id and update their name, but i could not successed. I tried every solution on the internet.
Here, i tried findOneAndUpdate() function, i can find by their “_id”s but i can not change the name of a person.
`export const PATCH = async (request : NextRequest) => {
try {
const data = await request.json();
await ConnectDB();
const url = request.url;
const id = url.split('/').pop();
const application = await Application.findOneAndUpdate({_id : id}, {$set: data}, {new: true})
return NextResponse.json({ application, id, data }, { status: 200 });
} catch (error) {
return NextResponse.json({ message: "Application Cannot be updated"}, { status: 401 })
}
}`