I'm currently working with hapi and I've come across an issue that I can't seem to find any solution for or previous mention of. When I send the following request only my first query parameter is in the 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 {}
and ''
replaced with actual names.
My route is currently written as 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 I do a console.log(resource_id)
I get "undefined" in the console. hapi's documentation states that all query parameters should be found in the request.query
object. For some reason this isn't happening. I've looked at the hapijs documentation, looked over my API call, and I've read people's examples of handling query params. Any idea what's going on here?