score:0

Forgive me, I didn't read all of your code, but are you sure that's the JSON response? My Spidey sense says that since < is often the first character of an HTML or XML response, maybe that's what you're getting. Are you sure that's not being returned?

score:0

If you mean to return a JSON content-type, the easiest way is to leverage the dedicated method of the response in Express:

router.get('/test', function(req, res){
    knex.select('*').from('test')
    .then(data => res.json(data))    // <-- note the "json"
})

However, the JSON data you show on the post aren't valid: it misses the colon ":" character as separator between key (i.e. "RowDataPacket") and the value (i.e. the braces).

More likely, should be this:

[
  RowDataPacket: { id: 1, name: 'test' },
  RowDataPacket: { id: 2, name: 'test1' },
  RowDataPacket: { id: 3, name: 'test2' },
  RowDataPacket: { id: 4, name: 'test3' },
  RowDataPacket: { id: 5, name: 'test4' },
  RowDataPacket: { id: 6, name: 'test5' }
]

Related Query

More Query from same tag