javascript - Hapijs query parameters undefined -
i'm working hapi , i've come across issue can't seem find solution or previous mention of. when send following request first query parameter in request.query object.
curl -h "content-type: application/json" -x put https://localhost:3000/lists/{username}/{listname}?token='token'&resource_id='resource_id'
with items in {}
, ''
replaced actual names.
my route written such
server.route({ method: 'put', path: '/lists/{username}/{listname}', handler: function(request, reply) { const username = encodeuricomponent(request.params.username); const listname = encodeuricomponent(request.params.listname); const resource_id = request.query.resource_id; const token = request.query.token; console.log(request.query); verify(token, username, {callback}, listname, resource_id, reply); } });
the console.log
call results in
{ token: 'token' }
if console.log(resource_id)
"undefined" in console. hapi's documentation states query parameters should found in request.query
object. reason isn't happening. i've looked @ hapijs documentation, looked on api call, , i've read people's examples of handling query params. idea what's going on here?
the issue curl command not hapijs.
try running curl -h "content-type: application/json" -x put "https://localhost:3000/lists/{username}/{listname}?token=token&resource_id=resource_id"
it's ampersand in query string being interpreted end of command. explanation why command wasn't working see this questions answer
Comments
Post a Comment