Last active
December 12, 2019 14:24
-
-
Save allpwrfulroot/b741b18dd53645f9df679a23775bf958 to your computer and use it in GitHub Desktop.
API route that invokes the getMDXInfo utility for the 'projects' directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { getMDXInfo } from 'utils/get-meta' | |
export default async (req, res) => { | |
if (req.method !== 'GET') { | |
return (res.statusCode = 401) | |
} | |
res.setHeader('Content-Type', 'application/json') | |
try { | |
const { list } = await getMDXInfo('projects') | |
res.status(200).json({ projects: list }) | |
} catch (error) { | |
res.status(400).json({ error }) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment