1. #1
    Sencha User
    Join Date
    Mar 2010
    Posts
    25
    Vote Rating
    1
    BigSeanDawg is on a distinguished road

      0  

    Default Answered: Proxy API with url parameter substitution?

    My application talks to a very RESTful API, and part of that is that "artifact' updates need to be POSTed to "/artifact/{id}". Is there any way to use this kind of variable substitution in the URL of a Model's proxy API? I didn't see it looking through the docs or source code, so if not, can anyone recommend the best place to plug this in?

    This is basically what I'm trying to get working:

    Code:
    Ext.define('jx.model.Artifact', {
        extend: 'Ext.data.Model',
        requires: [
            'Ext.data.proxy.Ajax',
            'Ext.data.reader.Json'
        ],
        fields: [{
            name: 'id',
            mapping: '_id'
        }, {
            name: 'name',
            mapping: 'name'
        }],
        
        proxy: {
            type: 'ajax',
            reader: {
                type: 'json',
                totalProperty: 'total_rows',
                root: 'rows'
            },
            api: {
                create: 'artifacts',
                read: 'artifacts',
                update: 'artifact/{id}' // <--- HERE
            }
        },

  2. Have you tried using Rest proxy instead of Ajax?

  3. #2
    Sencha - Senior Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    38,215
    Vote Rating
    1045
    Answers
    3645
    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

    Have you tried using Rest proxy instead of Ajax?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Software Engineer
    ________________
    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
    Mar 2010
    Posts
    25
    Vote Rating
    1
    BigSeanDawg is on a distinguished road

      0  

    Default

    Well that was obvious! I guess I just didn't see that class in the list. Thank you!

    This is much better than what I started to do, which to create a class named Ext.ux.data.proxy.AjaxWithUrlParameterSubstitution

Thread Participants: 1

Tags for this Thread