Timeout is the time limit that a web request can not pass. For example, if I define a timeout of 3 seconds, the web request while requesting the data, is canceled if it exceeds 3 seconds. I would like my web service not to exceed 3 seconds.
How can I do it?
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';
import { map } from 'rxjs/operators';
import { Observable } from 'rxjs/Observable';
import { GLOBAL } from '../app.constantes';
@Injectable()
export class AppService{
public url: string;
constructor(
public _http: HttpClient
){}
getAll(url,method,param): Observable<any>{
let config={};
config["timeout"]=3000;
config["data"]=param ? param: {}; //in case of POST this is the "data" property, with GET is "params" I believe..
return this._http.post(url,config);
}