Results 1 to 2 of 2

Thread: Template like Approach to Rest Proxy API URLs?

  1. #1
    Sencha User Trozdol's Avatar
    Join Date
    Jan 2009
    Location
    Nashville
    Posts
    64
    Answers
    2

    Default Template like Approach to Rest Proxy API URLs?

    I've been dealing with a somewhat inconsistent API. And I was wondering if anything like the below example is possible in a Model proxy? I think I saw something that looked similar on the web, but I can't find it and I don't think it was for this anyways. This issue has been driving me crazy. I know it's mostly due to the API I'm working with and have done what I can to communicate the needs. I've looked at buildUrl in the docs and it's pretty brief on actual usage and I seem to only get errors with it.

    If anyone has any ideas about the below or direction I could take to not have to code work arounds for all these that would be awesome!

    Thanks!

    Code:
    Ext.define('SomeApp.model.day.TradingStrategy', {    
         extend: 'SomeApp.model.Base',
    
        idProperty: 'strategy',
    
        fields: [
            'comments',
            'user_id',
            'day_id',
            'flow',
            'high',
            'low',
            'product',
            'strategy' // id field 
        ],
    
         proxy: {        type: 'rest',
            url: API_URL + '/trading',
            api: {
                create  : API_URL + '/trading',
                read    : API_URL + '/trading/{day_id}',
                update  : API_URL + '/trading',
                destroy : API_URL + '/trading/{day_id}/{strategy}'
            },
    
            // id to use for adding to end of URL
            idParam: 'day_id',
            appendId: true,
        
            paramsAsJson: true,
    
            // outgoing data
            writer: {
                type: 'json',
                rootProperty: 'TradingStrategy',
                writeAllFields: true
            },
    
            // incoming data
            reader: {
                type: 'json',
                rootProperty: 'XmlResponse[0].TradingStrategy'
            }
        }
    });
    Shayne Trosdahl
    @Trozdol
    CodePen

  2. #2
    chramer's Avatar
    Join Date
    Feb 2011
    Location
    Chisinau, Moldova
    Posts
    316
    Answers
    64

    Default

    I think you are talking about this: http://docs.sencha.com/extjs/6.2.0/c...html#cfg-proxy. But I don't see how it will help you solve your problem. I believe you should tweak the "buildUrl" method for this particular case.

Similar Threads

  1. Replies: 3
    Last Post: 8 Jun 2016, 6:05 AM
  2. Store proxy not using api urls to post updates
    By wayne_hurley in forum Ext 5: Q&A
    Replies: 10
    Last Post: 21 May 2015, 4:46 AM
  3. Relative urls show an error in a proxy
    By mark0978 in forum Sencha Architect 3.x: Q&A
    Replies: 7
    Last Post: 20 May 2015, 5:20 AM
  4. Dynamic Proxy URLs
    By stephenr85 in forum Sencha Touch 2.x: Examples and Showcases
    Replies: 2
    Last Post: 25 Sep 2012, 10:23 AM
  5. Replies: 2
    Last Post: 5 Sep 2012, 7:29 AM

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
  •