I am working on one project where we are using search bar to search data from server and for that we are calling API on every character type.
Due to that if user types 10-20 characters in search bar it will call 20 requests.
Among 19 request no required at all so I want to cancel all perior request from advanced HTTP plugin in ionic 3.
Is there any way to cancel that request which is already in process ?
I am using below code for HTTP call:
this.httpPlugin.setRequestTimeout(60);
// this.httpPlugin.setHeader("content-type", "application/json");
this.httpPlugin.setHeader('authorization', "Bearer " + token);
console.log('Requested URL :-', this.url + 'faqmsDetails/faList?caseNum=' + searchText);
this.httpPlugin.get(this.url + searchText, {}, {}).then((response) => {
console.log("Response Success : " + JSON.stringify(response));
let jsonResponse = JSON.parse(response.data);
console.log("JSON OBJECT RESPONSE : " + jsonResponse);
resolve(jsonResponse);
}).catch(error => {
reject(error);
});
I search a lot but didn't find any fruitful solution.
for Search delay i have used debounce property of searchebar which will help me to delay in search while user typing but still some request are unwanted in process so I want to cancel that requests.
Let me know if any one have any solution or suggestions.