import withSession from 'hocs/withSession' import ytpl from 'ytpl' export default withSession(async (req, res) => { switch (req.method) { case 'POST': try { const user = req.session.get('user') const { id } = req.body if (!user || !user?.isVerified || !id) { throw new Error('Something went wrong') } const info = await ytpl(id, { gl: user.language || 'en' }) res.status(200).json(info) } catch (error) { res.status(400).json([]) } break default: res.status(400).send() break } })