SQL-queries in server.js or in react-component file?

44
January 12, 2019, at 5:20 PM

I'm totally new at using Express.js and React.js and need advice on how I should structure my code.

So, basically: I have a webapplication all done in React. This react-app is connected to an express-backend, and I also have a mysql database connected to the express-backend. I have a server.js file (backend), that handles the connection to the database and the webapplication.

Let's say I have Groceries-component with a button "Add groceries", and once it's clicked it will add all data from a table called "Groceries" into a dropdown.

So my question is: where should I call the SQL-query for that? In the server.js file or in my Groceries-component?

READ ALSO
Laravel app using Jaws Maria DB on Heroku getting MYSQL errors

Laravel app using Jaws Maria DB on Heroku getting MYSQL errors

I have a Laravel app on Heroku using Maria DB as a Add onMy App is up and running

22
How can I modify the jetpack code so that when I publish a post and jetpack publish it on twitter does not show the url of the new post?

How can I modify the jetpack code so that when I publish a post and jetpack publish it on twitter does not show the url of the new post?

Hi ppl i need help with this because it shows the url in twitter and it comes from and ugly subdomain so i dont want to show the url of the new post just send a tweet with text

40
How to write ApplicationContext xml equivalent java code

How to write ApplicationContext xml equivalent java code

I want to make java based configurationI have already xml configuration in my project and it's worked

56
How to fix “mainflipSelectors[i].find” error in jQuery?

How to fix “mainflipSelectors[i].find” error in jQuery?

I am building a webpage where I need to display some details about a few peopleEach person's details is in the form of a card which goes by this structure:

54