Created
August 5, 2021 08:06
-
-
Save cdl/63819ae9a74b90d66942ab7f7d0939f1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
diff --git a/pages/api/posts/create.js b/pages/api/posts/create.js | |
index e45df89..f995100 100644 | |
--- a/pages/api/posts/create.js | |
+++ b/pages/api/posts/create.js | |
@@ -27,7 +27,7 @@ const handlePOST = async (req, res) => { | |
const user = await getUserFromJWT(token); | |
// Otherwise, post passes validations, let's create it. | |
- const post = await createPost({ title, content, authorId: user.id ?? null }); | |
+ const post = await createPost({ title, content, authorId: user?.id ?? null }); | |
return res.json({ success: true, post }); | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment