Output only JSON values using NodeJS Express for an API

I’m creating an API using NodeJS and Express and can create my JSON response after querying my database. I want to minimize the size of the response and only output the values and not the keys. Here is the response I am creating.

const api = (req, res) => {
    pool.query(query, (err, response) => {
        if (err){

The response from the query is a simple table (I’m omitting columns to simplify).

Time Values
1 50
2 40
3 70
4 10

The actual JSON response is:


My target output is:


Is there a simple option to change with this line?


Or do I need to manipulate the response form the query to remove the column headers? I’m using Postgres and not sure how I would do that?


response.rows.map( row => {
  return [row.Time, +row.Values];

Leave a Reply

Your email address will not be published. Required fields are marked *