cujojs / rest

RESTful HTTP client for JavaScript
http://cujojs.com/
Other
1k stars 146 forks source link

Default params cannot be overwritten #180

Closed illuminatedspace closed 5 years ago

illuminatedspace commented 6 years ago

The docs for template interceptor defines the config params property as:

default params to be combined with request.params

The template config params should be a default, as in they can be overwritten by the request.params. However the template config params cannot be overwritten by the request params.

This is the behavior I expected from reading the docs:

var client = rest.wrap(template, { params: { lang: 'en-us', section: 'introduction' } })

client({
  path: '/example/path/{section}{?lang}',
  params: {
    section: 'glossary'
  }
})

// response.url -> /example/path/glossary?lang=en-us

This is current behavior:

var client = rest.wrap(template, { params: { lang: 'en-us', section: 'introduction' } })

client({
  path: '/example/path/{section}{?lang}',
  params: {
    section: 'glossary'
  }
})

// response.url -> /example/path/introduction?lang=en-us
scothis commented 5 years ago

rest.js is no longer maintained