Skip to content

Instantly share code, notes, and snippets.

@SaurabhLpRocks
Created May 10, 2018 09:10
Show Gist options
  • Select an option

  • Save SaurabhLpRocks/b627b6d6972c31d6733a7d697e3e39b8 to your computer and use it in GitHub Desktop.

Select an option

Save SaurabhLpRocks/b627b6d6972c31d6733a7d697e3e39b8 to your computer and use it in GitHub Desktop.
import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {Observable} from 'rxjs';
import {share} from 'rxjs/operators';
@Injectable()
export class AppService {
data: Observable < any >;
constructor(private http : HttpClient) {
this.data = this.http.get<any> ('apiUrl').pipe(share());
}
getData() {
return this.data;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment