1

Made a new Foxx app with the Web UI and added the following route:

controller.get('/names/:name', function (request, response) {
  var name = request.params('name');

  response.json(db._query(
    "FOR x IN collection"+
      " FILTER x.name == " + name +
      " RETURN x"
    ).toArray());
})
.pathParam('name', { // line 112
  description: 'A name value to search for',
  type: 'String'
})
.errorResponse(ArangoError, 404, 'Data not found');

Which gives an error pointing to line 112 and prevents the app from running:

http://puu.sh/kEx6h/5641b92739.png

This runs fine if the .pathParam function is removed.

How can I fix this/what am I doing wrong? I'm using a fresh install with version 2.6.9 (latest)

reoh
  • 282
  • 5
  • 12

2 Answers2

1

AFAIK the type sub-attribute in .pathParam()'s second parameter was changed in version 2.5 to use joi. So it needs to be changed to:

.pathParam('name', { // line 112
  description: 'A name value to search for',
  type: joi.string() // this line needs changing
})

Apart from that, you will need to require joi in the controller beforehand, i.e.

var joi = require('joi');

That tutorial is indeed out of date and needs fixing.

stj
  • 9,037
  • 19
  • 33
  • Great! I had another look at the tutorial and noticed incorrect syntax on page 10: `.pathParam('id', .pathParam('id', firstCollectio...` – reoh Oct 12 '15 at 11:04
  • should also be fixed by now – stj Oct 12 '15 at 14:47
0

So, according to the latest controller docs, it seems the use of joi is now required.

Reason for the error was, I was following the Foxx tutorial which doesn't use joi.

reoh
  • 282
  • 5
  • 12