Fix item claiming in RSVP submission - Handle JSON stringification in backend, improve response handling

This commit is contained in:
2025-04-30 14:04:29 -04:00
parent 221b54a21f
commit 2da352ee9e
2 changed files with 7 additions and 3 deletions

View File

@@ -125,12 +125,15 @@ app.post('/api/events/:slug/rsvp', async (req, res) => {
return res.status(404).json({ error: 'Event not found' });
}
// Create a new RSVP with the submitted data
const result = await db.run(
'INSERT INTO rsvps (event_id, name, attending, bringing_guests, guest_count, guest_names, items_bringing) VALUES (?, ?, ?, ?, ?, ?, ?)',
[event.id, name, attending, bringing_guests, guest_count, guest_names, items_bringing]
[event.id, name, attending, bringing_guests, guest_count, guest_names, JSON.stringify(items_bringing || [])]
);
res.status(201).json(result);
// Fetch the newly created RSVP to return in response
const newRsvp = await db.get('SELECT * FROM rsvps WHERE id = ?', result.lastID);
res.status(201).json(newRsvp);
} catch (error) {
console.error('Error creating RSVP:', error);
res.status(500).json({