Skip to content
Discussion options

You must be logged in to vote

It looks like the issue may be a combination of SQL query syntax errors and incorrect variable names in the front-end code. Here's a detailed breakdown and resolution for each section of the code.

Backend (Controller API)

SELECT query: This query looks fine. It fetches the user with a specific id.
UPDATE query: There's an issue with the UPDATE SQL query syntax. It should use SET with individual columns to update, not VALUES. The corrected query should look like this:

.js

 export const editUser = (req, res) => {
  const q = "SELECT * FROM users WHERE id = ?";
  const userId = req.params.userId;

  db.query(q, [userId], (err, data) => {
    if (err) return res.status(409).json(err);

    //…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by NitishKumar525
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants