We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to intercept XHR http call in angular

Hi, 

I want to intercept ajax calls in file manager to retry same operation in case if it is failed for certain http code. is it possible to do it? 


Thanks

Sathiya


2 Replies

SS Sivakumar ShunmugaSundaram Syncfusion Team January 9, 2023 04:19 PM UTC

Hi sathiya,


Greetings from Syncfusion support.


With the shared details, you need to intercept ajax calls in the FileManager to retry the same operation in case it is failed for a certain http code. In our FileManager component, you can be able to capture every ajax request using FileManager beforeSend event and also can be able to capture the FileManager ajax requests failure using the FileManager failure event. Using the mentioned event, you can be able to make your own customization in the FileManager component.


Refer to the below code snippet.

[app.component.html],

 

<div class="sample-container">

  <ejs-filemanager

    id="file"

    #fileObj

    [ajaxSettings]="ajaxSettings"

    [allowDragAndDrop]="true"

    (beforeSend)="onbeforeSend($event)"

    [toolbarSettings]="toolbarSettings"

    (failure)="failure($event)"

  >

  </ejs-filemanager>

</div>

 

 


[app.component.ts],

 

export class AppComponent {

    @ViewChild('fileObj')

    public fileObj: FileManagerComponent;

...

    failure(args) {

      console.log(args);

      //Here you can make your customization while ajax request fails

    }

    ...

    onbeforeSend(args) {

      console.log(args);

      //Here you can find the every ajax request in the FileManager componnent

    }

  }

 

 


Sample: https://stackblitz.com/edit/angular-oqb6mk-nffhxp?file=app.component.ts


Check the shared sample for your reference.



SA sathiya replied to Sivakumar ShunmugaSundaram January 13, 2023 02:45 PM UTC

thank you


Loader.
Up arrow icon