Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Gatsby Example Endpoint
export default async function handler(req, res) {
const {
query: { name }
} = req;
try {
if (!name) {
throw new Error();
}
res.status(200).json({ message: 'A ok!', data: `Hello ${name} from the server` });
} catch (error) {
res.status(500).json(error);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment