Results 1 to 3 of 3

Thread: How pass additional parameters to index action in Rest proxy?

  1. #1
    Sencha User
    Join Date
    Oct 2012
    Location
    Poland
    Posts
    70
    Answers
    4
    Vote Rating
    5
      0  

    Default Answered: How pass additional parameters to index action in Rest proxy?

    Hi,

    I'd like to add a static param to be sent when fetching records using Rest proxy. I tried adding it to "extraParams" in proxy config, but then they are sent on *every* request, while I want them to be sent only on index action.

    Also, I'm currently dynamically adding authentication token to every request in "beforeload" and "beforesync" listeners (it sucks that extraParams can't be a function that returns an object).

    What's the best way to add custom params just to "index" requests?

    Cheers,
    Szymon

  2. As the docs state, extraParams will be included in every request so yes, you would have to listen to beforeload/beforesync to add params to the request.

  3. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,317
    Answers
    3881
    Vote Rating
    1291
      0  

    Default

    As the docs state, extraParams will be included in every request so yes, you would have to listen to beforeload/beforesync to add params to the request.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    Oct 2012
    Location
    Poland
    Posts
    70
    Answers
    4
    Vote Rating
    5
      0  

    Default

    Thanks.

    It sucks that extraParams can't be a function, because now I have to set the same thing in beforeload and beforesync handlers. It would be awesome if I could do something like this:

    Code:
    config: {
      extraParams: function () {
        return { auth_token: MyApp.user.getAuthToken() }
      }
    }
    and then just add additional filtering params to index requests in beforeload handlers.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •