I have been attempting to locate clients by their ID and update their name, but so far I haven't been successful. Despite trying numerous solutions from various sources online.
Specifically, when using the findOneAndUpdate() function, I am able to identify clients based on their "_id", however, I cannot seem to modify a person's name successfully.
`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 })
}
}`