1. #1
    Sencha User
    Join Date
    Oct 2012
    Location
    Poland
    Posts
    70
    Vote Rating
    5
    Answers
    4
    szimek is on a distinguished road

      0  

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

    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 - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,647
    Vote Rating
    898
    Answers
    3575
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      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 @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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
    Vote Rating
    5
    Answers
    4
    szimek is on a distinguished road

      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.

Thread Participants: 1

Tags for this Thread