Skip to content

Instantly share code, notes, and snippets.

@odhiambo123
Created September 15, 2022 04:44
Show Gist options
  • Save odhiambo123/4742982383618d361b84aac1b96f7253 to your computer and use it in GitHub Desktop.
Save odhiambo123/4742982383618d361b84aac1b96f7253 to your computer and use it in GitHub Desktop.
get items from the api endpoint
import { Component, OnInit } from '@angular/core';
import {DataService} from "../../services/data.service";
@Component({
selector: 'app-category',
templateUrl: './category.component.html',
styleUrls: ['./category.component.css']
})
export class CategoryComponent implements OnInit {
categories : any[] = [];
constructor(private dataService: DataService) { }
ngOnInit(): void {
this.dataService.getCategories().subscribe((response: any) => {
this.categories = response.data;
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment