Create and Display Comments
Fullstack Social iOS NodeJS REST
With our HTML form now created, we're going to enable our server so that it can consume comments for different posts in the system. First we'll expose a route that takes in a post slug id. Next we can read the text information from our request body and create a brand new comment object that will be associated to the current post. Finally we need to display all comments in a vertical list that belong to the post details page. Doing so using a v-for loop in Vue will be super simple.

Comments (2)
Udin Rajkarnikar
3 years ago
<form :action ="'/post/comment/'+ post.id" method= "POST"> Routes.js --> 'POST /post/comment/:id': 'user/commentCreate', Hello Brian, my Routes are not working properly. It shows 404 when I click the comment button. Any insights on what's going on here? Thanks!
Udin Rajkarnikar
3 years ago
Never Mind! Found the error.
gerkov77
2 years ago
Hi Brian, great stuff there! One thing made me wonder! Coming from Swift, I was really surprised, that we could assign a new property to Post: – comments. Post model does not have that attribute. So is this basically possible in JavaScript to simply apply new properties to data in a method without the model struct having it out of the box? If so, this is a very weird weird language. Or maybe Post is not even a struct or class, only an object of some sort which is extensible on the go?
HELP & SUPPORT