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

418
Views
Node.js Error ( Cannot GET /api/events/100 ) ( single Get , Post ) SQL Server 2019

i create API With Node.js and SQL Server and its working normally with Get All Data I tested it with postman (200) .. index.js page

const getEvents = async () => {
try {
    let pool = await sql.connect(config.sql);
    const sqlQueries = await utils.loadSqlQueries('events');
    const eventsList = await pool.request().query(sqlQueries.eventslist);
    return eventsList.recordset;
} catch (error) {
    console.log(error.message);
}

}

and the eventController.js page

const getAllEvents = async (req, res, next) => {
try {

    const eventlist = await eventData.getEvents();
    res.send(eventlist);        
} catch (error) {
    res.status(400).send(error.message);
}

}

and eventlist.sql

SELECT [employee_id]
  ,[first_name]
  ,[last_name]
  ,[email]
  ,[phone_number]
  ,[hire_date]
  ,[job_id]
  ,[salary]
  ,[manager_id]
  ,[department_id]

FROM [sales].[dbo].[employees]

******************* But with read single post (Error) index.js page

const getById = async(eventId) => {
try {
    let pool = await sql.connect(config.sql);
    const sqlQueries = await utils.loadSqlQueries('events');
    const event = await pool.request()
                        .input('employee_id', sql.Int, eventId)
                        .query(sqlQueries.eventbyId);
    return event.recordset;
} catch (error) {
    return error.message;
}

}

And and the eventController.js page

const getEvent = async (req, res, next) => {
try {
    const eventId = req.params.id;
    const event = await eventData.getById(eventId);
    res.send(event);
} catch (error) {
    res.status(400).send(error.message);
}
}

and eventlbyId.sql

SELECT [employee_id]
  ,[first_name]
  ,[last_name]
  ,[email]
  ,[phone_number]
  ,[hire_date]
  ,[job_id]
  ,[salary]
  ,[manager_id]
  ,[department_id]

FROM [sales].[dbo].[employees] WHERE [employee_id]=@employee_id

the Res From postman

    <pre>Cannot GET /api/events/100</pre>
about 4 years ago · Juan Pablo Isaza
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!