BoLaMN / loopback-component-admin

Loopback Admin Component
55 stars 25 forks source link

JSON only parameters #6

Closed MarkAndrewJohnson closed 8 years ago

MarkAndrewJohnson commented 8 years ago

This component only works with JSON filter parameters, not traditional style parameters (ie filter[where][foo]=bar). The following code breaks, and should probably only parse as JSON if args is a string and not already an object.

On line 27: filter = JSON.parse(ctx.args.filter).where;

BoLaMN commented 8 years ago

Can wrap a try/catch around it to facilitate both instances maybe?

filter = ctx.args.filter

try filter = JSON.parse ctx.args.filter catch e

might do the trick?