Skip to content

Instantly share code, notes, and snippets.

@israeljrs
Created February 18, 2019 16:25
Show Gist options
  • Save israeljrs/e761be07fb9f0cb790b84db1121871c8 to your computer and use it in GitHub Desktop.
Save israeljrs/e761be07fb9f0cb790b84db1121871c8 to your computer and use it in GitHub Desktop.
exemplo de service.
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { timeout } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
export class WebRequestService {
constructor(public http: HttpClient) { }
getArticle(): Observable<any> {
return this.http.get<any>('http://slowwly.robertomurray.co.uk/delay/2000/url/https://jsonplaceholder.typicode.com/todos/1')
.pipe(
timeout(1000)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment