--- tags: music-library,solution,track --- # Getting an artist by id ```javascript= // src/controllers/artist.js ... exports.readById = async (req, res) => { const db = await getDb(); const { artistId } = req.params; const [[artist]] = await db.query('SELECT * FROM Artist WHERE id = ?', [ artistId, ]); if (!artist) { res.sendStatus(404); } else { res.status(200).json(artist); } db.end(); }; ... ``` ```javascript= // src/routes/artist.js ... router.get('/:artistId', artistController.readById); ... ```