Skip to content

Instantly share code, notes, and snippets.

@wpflames
Created June 28, 2022 10:02
Show Gist options
  • Select an option

  • Save wpflames/25975a74f06011906a24399fa784ecae to your computer and use it in GitHub Desktop.

Select an option

Save wpflames/25975a74f06011906a24399fa784ecae to your computer and use it in GitHub Desktop.
Get data from server
import { HttpClient } from '@angular/common/http';
import { Component } from '@angular/core';
@Component({
selector: 'posts',
templateUrl: './posts.component.html',
styleUrls: ['./posts.component.scss']
})
export class PostsComponent {
posts: any[];
constructor(http: HttpClient) {
http.get('https://jsonplaceholder.typicode.com/posts').subscribe(response => {
console.log(response);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment