title: How do I solve QueryResultError in pg-promise
body: <p>Please I am seeing the QueryREsultError when I tested my code in Postman. I am using node.js, express.js, and pg-promise. On testing, the user is created in the Postgres database as expected, but the response instead show <strong>QueryResultError</strong> with the data created and the query in my code as shown below. However, I wanted the response to display just the success message and the token generated. I don't know if the problem is with the <strong>db.none</strong> or the code not generating token. Find my code below:</p>
  
  <p><strong>CREATEUSER FUNCTION</strong></p>
  
  <pre><code>async createUser(req, res) {
      const hashedPassword = await bcrypt.hash(req.body.password, 10);
      const query = `insert into user_table(username, email, email_verified, password, role, created_at, last_login)
                    VALUES ($1, $2, $3, $4, $5, $6, $7) returning *`;
    const values = [req.body.username, req.body.email, req.body.email_verified, hashedPassword, req.body.role, 'now()', 'now()'];
  
    try {
      const { rows } = await db.none(query, values);
      const token = Helper.generateToken(rows[0].username);
    return res
      .status(200)
      .cookie('jwt', token, {
        httpOnly: true
      })
      .json({
        success: true
      });
  } catch (err) {
      return res.json(err);
    }
  },
  </code></pre>
  
  <p><strong>Helper.generateToken</strong></p>
  
  <pre><code>generateToken(username) {
      const token = jwt.sign({
        username: username
      },
        process.env.JWT_SECRET, { expiresIn: '7d' }
      );
      return token;
    }
  }
  </code></pre>
  
  <p><strong>ERROR SHOWING</strong></p>
  
  <pre><code>{
      "name": "QueryResultError",
      "code": 1,
      "result": {
          "command": "INSERT",
          "rowCount": 1,
          "oid": 0,
          "rows": [
              {
                  "id": "8af645cd-5ce5-496a-b07f-db98f4897fee",
                  "username": "juljgggg",
                  "email": "t@yahoo.com",
                  "email_verified": "t@yahoo.com",
                  "password": "$2a$12$UmQJ6qKP4nhrWS9kYxySGuBIWv5eyOHzbKtjvLzRQS5qL5bGRssym",
                  "role": "Subscriber",
                  "created_at": "2020-01-27T13:43:38.122Z",
                  "last_login": "2020-01-27T13:43:38.122Z"
              }
          ],
          "fields": [
              {
                  "name": "id",
                  "tableID": 42033,
                  "columnID": 1,
                  "dataTypeID": 2950,
                  "dataTypeSize": 16,
                  "dataTypeModifier": -1,
                  "format": "text"
              },
              {
                  "name": "username",
                  "tableID": 42033,
                  "columnID": 2,
                  "dataTypeID": 25,
                  "dataTypeSize": -1,
                  "dataTypeModifier": -1,
                  "format": "text"
              },
              {
                  "name": "email",
                  "tableID": 42033,
                  "columnID": 3,
                  "dataTypeID": 25,
                  "dataTypeSize": -1,
                  "dataTypeModifier": -1,
                  "format": "text"
              },
              {
                  "name": "email_verified",
                  "tableID": 42033,
                  "columnID": 4,
                  "dataTypeID": 25,
                  "dataTypeSize": -1,
                  "dataTypeModifier": -1,
                  "format": "text"
              },
              {
                  "name": "password",
                  "tableID": 42033,
                  "columnID": 5,
                  "dataTypeID": 25,
                  "dataTypeSize": -1,
                  "dataTypeModifier": -1,
                  "format": "text"
              },
              {
                  "name": "role",
                  "tableID": 42033,
                  "columnID": 6,
                  "dataTypeID": 25,
                  "dataTypeSize": -1,
                  "dataTypeModifier": -1,
                  "format": "text"
              },
              {
                  "name": "created_at",
                  "tableID": 42033,
                  "columnID": 7,
                  "dataTypeID": 1114,
                  "dataTypeSize": 8,
                  "dataTypeModifier": -1,
                  "format": "text"
              },
              {
                  "name": "last_login",
                  "tableID": 42033,
                  "columnID": 8,
                  "dataTypeID": 1114,
                  "dataTypeSize": 8,
                  "dataTypeModifier": -1,
                  "format": "text"
              }
          ],
          "_parsers": [
              null,
              null
          ],
          "_types": {
              "_types": {code ommitted
                  }
              },
              "text": {},
              "binary": {}
          },
          "RowCtor": null,
          "rowAsArray": false,
          "duration": 40
      },
  
  }
  </code></pre>