Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

113
Views
Missing initializer in destructing declaration / identifier 'name' has already been declared [mysql][nodejs]

When I try to insert keys as params i receve this errors on nodemon: SyntaxError: Identifier 'name' has already been declared

this is my function on model:

const create = async (name, about, site) => {
    const sql = 'INSERT INTO client (name, about, site) VALUES (?, ?, ?)', [name, about, site];
    const [result] = await connection.execute(sql);
    return result;
};

and my route:

router.post('/', async (req, res) => {
  const { name, about, site } = req.body;
  const data = await create(name, about, site);
  res.status(200).json(data);
})

this is my first crud. how i resolve this errors?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You cannot assign both the SQL string and the parameters array to one constant sql. What you probably mean is

const create = async (name, about, site) => {
  const [result] = await connection.execute(
    'INSERT INTO client (name, about, site) VALUES (?, ?, ?)',
    [name, about, site]
  );
  return result;
};
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!