Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48980

Ionic Native http abort request is not working (Json error)

$
0
0

Hi,

I am using ionic Native http plugin for call the API’s

I want to abort previous http request. So as per the GitHub - silkimen/cordova-plugin-advanced-http: Cordova / Phonegap plugin for communicating with HTTP servers. Allows for SSL pinning! I implement abort() method for abort http request

if(this.requestId && this.requestId !="" ){
                  
    this.httpNative.abort(this.requestId).then(data =>{
        console.log("abort :",data)
        this.requestId = "";
    }).catch(error => {
        this.requestId = "";
        console.log('error 21212', error);
      
    
    });
}else{
    this.spinner = true
  
    this.requestId = this.httpNative.post(this.baseurl+'?action=apiGetBooks', {keyword:this.keyword}, {})
    .then(data => {
        this.spinner = false
        if(data.data){
            this.books = JSON.parse(data.data);
            if(this.books.length == 0){
                this.message = "No result found with <b>"+this.keyword.trim()+"</b>";
            }else{
                this.message = ""
            }
            console.log("data :",data)
        }
    }).catch(error => {
        this.spinner = false
        console.log('status', error.status);
        console.log('error',error.error); // error message as string
        console.log('error',error.error);
    });
}

abort() function is not working on the Android 8 and 8+V

abort() function is return in the errror called JOSN error.

Ionic:

Ionic CLI : 6.16.3 (C:\Users\Sohan\AppData\Roaming\npm\node_modules@ionic\cli)
Ionic Framework : @ionic/angular 5.6.10
@angular-devkit/build-angular : 12.0.5
@angular-devkit/schematics : 12.1.0
@angular/cli : 12.0.5
@ionic/angular-toolkit : 4.0.0

Cordova:

Cordova CLI : 10.0.0
Cordova Platforms : android 9.1.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 8 other plugins)

Utility:

cordova-res : 0.15.3
native-run : 1.4.0

System:

Android SDK Tools : 26.1.1 (C:\Users\Sohan\AppData\Local\Android\Sdk)
NodeJS : v14.17.1 (C:\Program Files\nodejs\node.exe)
npm : 7.8.0
OS : Windows 10

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 48980

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>