Skip to content

Instantly share code, notes, and snippets.

@gdyrrahitis

gdyrrahitis/pets.component.ts Secret

Created Aug 18, 2018
Embed
What would you like to do?
import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Component({
selector: 'app-pets',
templateUrl: './pets.component.html',
styleUrls: ['./pets.component.css']
})
export class PetsComponent implements OnInit {
private pets: string[] = [];
private url: string = "https://localhost:44350/api/pets";
constructor(private http: HttpClient) { }
ngOnInit() {
this.http.get<string[]>(this.url).subscribe(data => {
this.pets = data;
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.