ionic framework - How to use the timeout() in angular 2 -




am setting timeout in code keep getting error: typescript error property 'timeout' not exist on type 'observable'. how can solve this? in advance.

this code:

this.http.post(this.global.api_url + '/cancel_order', {id: product._id})     .timeout(10000)     .map(res => res.json())     .subscribe((data) => {         if (data.result.id != null && data.result.rev != null && data.result.ok == true && data.status == 201) {             this.global.toast("order canceled", "toast-error");             let del_data = [{_id: product._id, _rev: product._rev}];             this.orders.delcart(del_data);             loader_send_1.dismiss();             this.ngoninit();          } else {              this.global.toast("failed cancel order", "toast-error");              loader_send_1.dismiss();          } 

you either add import 'rxjs/add/operator/timeout'

or

you use standard javascript settimeout() function this:

settimeout(() => {     this.http.post(this.global.api_url + '/cancel_order', {id: product._id})         .map(res => res.json())         .subscribe((data) => {             if (data.result.id != null && data.result.rev != null && data.result.ok == true && data.status == 201) {                 this.global.toast("order canceled", "toast-error");                 let del_data = [{_id: product._id, _rev: product._rev}];                 this.orders.delcart(del_data);                 loader_send_1.dismiss();                 this.ngoninit();              } else {                  this.global.toast("failed cancel order", "toast-error");                  loader_send_1.dismiss();              } }, 1000) 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -