Displaying a different user's messages in the admin view

This commit is contained in:
Keith Stevens
2023-01-12 14:38:31 +09:00
parent be7f933033
commit 55635f1a27
4 changed files with 105 additions and 44 deletions
@@ -0,0 +1,16 @@
import { withRole } from "src/lib/auth";
const handler = withRole("admin", async (req, res, token) => {
const { user } = req.query;
const messagesRes = await fetch(`${process.env.FASTAPI_URL}/api/v1/frontend_users/local/${user}/messages`, {
method: "GET",
headers: {
"X-API-Key": process.env.FASTAPI_KEY,
},
});
const messages = await messagesRes.json();
res.status(200).json(messages);
});
export default handler;