change axios call

This commit is contained in:
Joseph J Helfenbein
2025-01-25 09:03:32 -05:00
parent 079eb19931
commit 6230662cbc
2 changed files with 12 additions and 6 deletions

View File

@@ -56,13 +56,18 @@ const AccountPage = () => {
}; };
const handleSave = async () => { const handleSave = async () => {
await axios.put(`/api/patients/${selectedPatient.email}`, { try {
await axios.put(`/api/patients?email=${selectedPatient.email}`, {
medications, medications,
medicalConditions: diagnoses, medicalConditions: diagnoses,
}); });
alert('Patient data updated successfully'); alert('Patient data updated successfully');
} catch (error) {
console.error('Error updating patient data:', error);
alert('Failed to update patient data');
}
}; };
if (!userData) return <div>Loading...</div>; if (!userData) return <div>Loading...</div>;
return ( return (

View File

@@ -20,13 +20,14 @@ export async function GET() {
} }
} }
export async function PUT(req, { params }) { export async function PUT(req) {
console.log('Processing patient update request...'); console.log('Processing patient update request...');
await connectDB(); await connectDB();
try { try {
const { email } = params; const url = new URL(req.url);
const email = url.searchParams.get('email');
if (!email) { if (!email) {
console.log('No email provided'); console.log('No email provided');