Results 1 to 3 of 3

Thread: Ext.data.proxy.Rest exception event always gives empty response.responseText

  1. #1
    Sencha Premium Member
    Join Date
    Feb 2016
    Location
    New Jersey
    Posts
    11

    Default Answered: Ext.data.proxy.Rest exception event always gives empty response.responseText

    Ext.data.proxy.Rest exception event always gives empty response.responseText

    We are using Ext.data.proxy.Rest and listen to the "exception" event in attempt to handle non-200 HTTP code return from our RESTful API. The event triggered but the response field that is included in the event function never captures the response body that the RESTful API returns. I have even looked into overriding the processResponse method but I am still not able to get a hold of the response. The response is in JSON format.

    How do I capture the message? Is there also a way to capture the return code such as 404, 500, or 503?

    Thanks a lot in advance,
    Ronald

  2. The event you need to listen to is "requestexception". I don't know what version you are using, so I don't know where/when a change was made to where to listen to that event.


    For example, when we used ext 4.1.1, we did it this way:
    Code:
    // For Handling Global Exception Errors 500, 404, 403, ...
    Ext.data.Connection.on('requestexception', this.onRequestException);
    
    
    // Handle redirect for requests when there is a timeout of some sort...
    Ext.data.Connection.on('requestcomplete', this.onRequestComplete);
    We then jumped directly to 5.x, so we had to chnage it to this:
    Code:
    Ext.mixin.Observable.observe(Ext.Ajax);
    Ext.Ajax.on({
        // For Handling Global Exception Errors 500, 404, 403, ...
        requestexception : this.onRequestException,
    
    
        // Handle redirect for requests when there is a timeout of some sort...
        requestcomplete : this.onRequestComplete
    });
    What I don't know is if the change happened in some later version of ext 4.x.


    See the API for the function signature. The response.status gives you the HTTP code.


    Hope this helps.

  3. #2
    Sencha Premium User
    Join Date
    Mar 2011
    Posts
    287
    Answers
    35

    Default

    The event you need to listen to is "requestexception". I don't know what version you are using, so I don't know where/when a change was made to where to listen to that event.


    For example, when we used ext 4.1.1, we did it this way:
    Code:
    // For Handling Global Exception Errors 500, 404, 403, ...
    Ext.data.Connection.on('requestexception', this.onRequestException);
    
    
    // Handle redirect for requests when there is a timeout of some sort...
    Ext.data.Connection.on('requestcomplete', this.onRequestComplete);
    We then jumped directly to 5.x, so we had to chnage it to this:
    Code:
    Ext.mixin.Observable.observe(Ext.Ajax);
    Ext.Ajax.on({
        // For Handling Global Exception Errors 500, 404, 403, ...
        requestexception : this.onRequestException,
    
    
        // Handle redirect for requests when there is a timeout of some sort...
        requestcomplete : this.onRequestComplete
    });
    What I don't know is if the change happened in some later version of ext 4.x.


    See the API for the function signature. The response.status gives you the HTTP code.


    Hope this helps.

  4. #3
    Sencha Premium Member
    Join Date
    Feb 2016
    Location
    New Jersey
    Posts
    11

    Default

    Thanks for your help. I have tried to listen to the requestexception event and I can see the error code when I do POST. However, using GET and the response does not come back with info that contains 503 error code. It just shows 0. I have tried both APIs via POSTMAN and they returned correctly. The responses were identical except that the POST call returns a 400 (Bad request) but GET call returns 503 (Server unavailable). The requestexception event was thrown in both cases. The response field contains everything I needed for the HTTP400 case, but the 503 case always return statusCode=0.

Similar Threads

  1. Extjs5: Observe event exception on every data proxy
    By t.nissen in forum Ext 5: Q&A
    Replies: 2
    Last Post: 27 Jul 2014, 10:31 PM
  2. Replies: 4
    Last Post: 24 May 2011, 1:07 AM
  3. empty response.responseText
    By josw in forum Ext GWT: Discussion
    Replies: 1
    Last Post: 19 May 2011, 1:04 AM

Posting Permissions

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