Skip to content

Instantly share code, notes, and snippets.

@alvarocamillont
Created June 1, 2019 04:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alvarocamillont/78a92ebabea640f32773f1fd3ee08c3a to your computer and use it in GitHub Desktop.
Save alvarocamillont/78a92ebabea640f32773f1fd3ee08c3a to your computer and use it in GitHub Desktop.
import { HttpClient } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import { People, Planet } from '../model/api';
@Component({
selector: 'app-example-sync',
templateUrl: './example-sync.component.html',
styleUrls: ['./example-sync.component.css']
})
export class ExampleSyncComponent implements OnInit {
people$: Observable<People>;
planet$: Observable<Planet>;
constructor(private http: HttpClient) {}
ngOnInit() {
this.people$ = this.http.get<People>('https://swapi.co/api/people/3/');
this.planet$ = this.http.get<Planet>('https://swapi.co/api/planets/5/');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment