简体   繁体   中英

Query issue for a forum done in ReactJS MySQL Node.js and Express

I am a junior developer and right now I'm building a simple forum using ReactJS, Node.js, Express and MySQL.

In the forum each Topic must have many many Posts.

I do not know if the problem comes from the back-end query or if it comes from the client side but the posts aren't well separated per topic. Right now I have all the posts from the posts table in topic 1 and again in topic 2.

Test Page

In the server folder here are my imports in index.js

Server side imports

and here are my queries for Posts.

Server side queries

Thank you for any help.

Have a very nice day, Ana

Your query seems ok, which will return all records by inner join with topics table. One more suggestion, use the below code to get the proper HTTP response code.

return res.status(200).send(result);

Also, use try...catch to handle exceptions as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM