How can you add a new column to an existing class?

I’m trying to post comments for an existing post, so when the button of post ccomment is clicked, it should save the data on the database inside the Posts column but it doesn’t work as I’m getting POST error. Is there anything wrong in Posting my data like this?

function Socialpostdetail() {
	const [item, setItems] = useState([])
	const [comment, setComment] = useState("")
	let {resultId} = useParams();
	const { Moralis, isInitialized } = useMoralis();
	console.log(comment)

	const { data, error, isLoading } = useMoralisQuery("Posts");
const createNewComment = async (e, content) => {

        e.preventDefault()

        const Posts = Moralis.Object.extend("Posts");

const query = await new Moralis.Query(Posts);

query.equalTo("title", resultId);

        const newComment = Moralis.Object.extend("Comments");

        const comment = new newComment();

        comment.set("content", content);

        comment.set("author", Moralis.User.current())

        comment.save();

        query.set("comments", comment)

        query.save();

      }
return(
<button type="submit" onClick={(e) => createNewComment(e, content)}>Post Comment</button>
)
}

I would expect this code to work, what is the error that you get?

it is redirecting me to a new URL with this error:

Cannot POST /socialpostdetail/refdv

Probably the issue is that the routing is associated with an ID?

at what line you get that error?

it just redirects me, there is no error on line

did you set properly your Moralis serverUrl?
everything else works fine? like authentication?

yes, everything works fine, i can’t seem to find out why this error is popping out. Maybe it has something to do with the routing?

that url with socialpostdetail seems strange, is there somewhere in your code?

yes yes, it is in the routing. It is connected with the id of the post

than maybe is a problem in that routing or what should be there on that routing

well usually in that routing is the post which is fetched according to the id and it does that well, but when I try to post the comment it redirects me to the image above

you could check the save part separately, to see if it works

okay perfect i found out where the error was. But can you put the comments class to an existing class?

like i want the comments to be inside a class named posts

you may be able to do that using pointers, you don’t have to do something special, but pointers would be used behind the scenes

are there any docs for pointer?

maybe this helps a little: https://coderwall.com/p/cy6cea/how-to-use-pointers-relations-parse-com-javascript-sdk

const createNewComment = async (e, content) => {

        e.preventDefault()

        const Posts = Moralis.Object.extend("Posts");

        const query = await new Moralis.Query(Posts);

        query.equalTo("title", resultId);

        const newComment = Moralis.Object.extend("Comments");

        const comment = new newComment();

        comment.set("content", content);

        comment.set("author", Moralis.User.current())

        comment.save();

        query.include("Comments");

      }

i’ve tried this but it does nothing, the comment doesn’t get added to the query, is the syntax correct?

does this part work fine? as in it creates a new row in Comments table?

yes, it does create the comment, but it doesn’t add it do the Posts query

I think that you have to add it separately to a Posts object