lau1944/bunrest

Cant get custom response

craftzneko opened this issue · 2 comments

New to this so probably missed something really obvious, no matter what i do i cant seem to get a custom response back when pusing put

app.put('/api/data', async (req, res) => {
  const { ComputerName, AgentVer, DateScanned, SummaryJSON } = req.body;

  // write a query to insert the data into the database
  const query = {
    text: 'INSERT INTO ICTSignal(ComputerName, AgentVer, DateCreated, SummaryJSON) VALUES($1, $2, $3, $4)',
    values: [ComputerName, AgentVer, DateScanned, JSON.stringify(SummaryJSON)],
  };

  // execute the query
  await client.query(query, (err) => {
    if (err) {
      console.log(err.stack);
      res.status(500).json({ message: 'Error in database operation' });
    } else {console.log(res.status)
      res.status(200).json({ message: 'Data inserted successfully' });
    }
  });
});

image

what am i doing wrong here