How do i access this javascript value?

I’m getting a javascript error returned from postgres using node ‘pg’.

Here is the code the generates the error

How the object is generated.

function storeDeviceState(ingres_id, info) {
        var deviceId;
        var insertDevice = client.query({
                text: "INSERT INTO devices (serialNumber, imeiNumber) VALUES ($1, $2)",
                values: [info.serialNumber, info.imeiNumber]
        }, function (error, results) {
                if (error) {
                        // [error: duplicate key value violates unique constraint "devices_serialnumber_key"
                } else {
                        deviceId = results.rows[0].id;

Below is a copy and paste of what I see in the console as a result of console.log(error);

{ [error: duplicate key value violates unique constraint "devices_serialnumber_key"]
  length: 130,
  name: 'error',
  severity: 'ERROR',
  code: '23505',
  detail: undefined,
  hint: undefined,
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  file: 'nbtinsert.c',
  line: '300',
  routine: '_bt_check_unique' }

Here’s what I’ve tried,


I can access the code for example by


Here are the results of JSON.stringify on the object.


Please help!

Problem courtesy of: bluekeys

Node.js Recipes责编内容来自:Node.js Recipes (源链) | 更多关于

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 前端开发 » How do i access this javascript value?

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录