// Get all candidates app.get('/api/candidates', (req, res) => { const sql = `SELECT * FROM candidates`; db.query(sql, (err, rows) => { if (err) { res.status(500).json({ error: err.message }); return; } res.json({ message: 'success', data: rows }); }); });
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter