Why not return params as Object?
strrchr opened this issue · comments
strrchr commented
before
let result = router.find('GET', '/users/233')
// => [handler, params]
// => [()=>{}, [{name: id, value: 233}]]
after
let result = router.find('GET', '/users/233')
// => [handler, params]
// => [()=>{}, {id: 233}]
Fangdun Tsai commented
Good catch!
Fangdun Tsai commented
@strrchr You can do that
let result = router.find('GET', '/users/233')
// => [handler, params]
// => [()=>{}, {id: 233}]
let params = {}
if (result[0]) {
result[1].forEach(param => params[param.name] = param.value)
}