Foxx service erroring out

31 views Asked by At

I am fairly new to this, so I wrote my first Foxx service and not seeing where the issue is. It supposed to query a collection and return back a single string value. Getting "errorMessage": "Internal Server Error" back for the code below.

'use strict';

const createRouter = require('@arangodb/foxx/router');
const router = createRouter();
const db = require('@arangodb').db;
const joi = require('joi');
const person = db._collection('person');

module.context.use(router);

router.get(
  '/person/:personId',
  function (req, res) {
      const result = db._query(aql`
         FOR p IN ${person}
         FILTER p.ascoId == ${req.pathParams.personId}
         RETURN p.address`).toArray();
      res.send(result);
  }
)
.pathParam('personId', joi.number().required(), 'Id to search on');

1

There are 1 answers

0
Roman On

This is resolved. The issue was with a missing aql import. Should have used this instead:

const {db, aql} = require('@arangodb');