/** * @copyright NHCarrigan * @license Naomi's Public License * @author Naomi Carrigan */ import { Injectable } from "@angular/core"; export type Product = Array<{ name: string; description: string; url: string | null; wip: boolean; category: "community" | "websites" | "apps"; premium: boolean; avatar: string | null; }>; @Injectable({ providedIn: "root", }) export class Products { private products: Product = []; public constructor() { } public async getProducts(): Promise { if (this.products.length > 0) { return this.products; } const request = await fetch("https://data.nhcarrigan.com/projects.json"); const data = await request.json() as Product; this.products = data; return data; } }