Add logging for post creation API requests and responses
Adds console logs to the /api/posts endpoint in server/index.ts to capture incoming payloads and successful post creation data, aiding in debugging. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9203795e-937a-4306-b81d-b4d5c78c240e Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: f65c3e3d-c2a9-489d-b74e-9278ae76aed3 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7c94b7a0-29c7-4f2e-94ef-44b2153872b7/9203795e-937a-4306-b81d-b4d5c78c240e/zMxtXds Replit-Helium-Checkpoint-Created: true
This commit is contained in:
commit
bf01287e20
1 changed files with 4 additions and 0 deletions
|
|
@ -2451,10 +2451,13 @@ export function createServer() {
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post("/api/posts", async (req, res) => {
|
app.post("/api/posts", async (req, res) => {
|
||||||
|
console.log("[API] POST /api/posts called");
|
||||||
const payload = req.body || {};
|
const payload = req.body || {};
|
||||||
|
console.log("[API] Payload:", JSON.stringify(payload).slice(0, 200));
|
||||||
|
|
||||||
// Validation
|
// Validation
|
||||||
if (!payload.author_id) {
|
if (!payload.author_id) {
|
||||||
|
console.log("[API] Error: author_id is required");
|
||||||
return res.status(400).json({ error: "author_id is required" });
|
return res.status(400).json({ error: "author_id is required" });
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
|
|
@ -2523,6 +2526,7 @@ export function createServer() {
|
||||||
.json({ error: error.message || "Failed to create post" });
|
.json({ error: error.message || "Failed to create post" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("[API] Post created successfully:", data?.id);
|
||||||
res.json(data);
|
res.json(data);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.error("[API] /api/posts exception:", e?.message || String(e));
|
console.error("[API] /api/posts exception:", e?.message || String(e));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue