Home:ALL Converter>Implementing rxjs Timeout with observable

Implementing rxjs Timeout with observable

Ask Time:2018-11-12T04:21:34         Author:Stephen Romero

Json Formatter

I am trying to Implement timeout with my http observable, but I don't think I'm handing the request correctly.

import { HttpClient,HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import 'rxjs/add/operator/retry';
import 'rxjs/add/operator/delay';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/timeout';


//POST form 
  submitForm(data,authToken){
    //console.log(data,authToken);
    const httpOptions = {
        headers: new HttpHeaders({
            'Accept': 'application/json, text/plain',
            'Content-Type':  'application/json',
            'Authorization': authToken
          })
 };
  return this.http.post(this.apisubmitFormUrl, JSON.stringify(data),
        httpOptions||{reportProgress:true})
        .retry(3)
        .timeout(15000)
        .delay(2000);

  }

From other page

this.stemAPI.submitForm(this.submitData,this.reap.token).subscribe((result) =>{  
   //handle response
   }, (err) => 
    { 
   //handle error
 });

Author:Stephen Romero,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/53252863/implementing-rxjs-timeout-with-observable
yy