Files
hikari/client/src/app/products.ts
T
naomi c8bd129c0f
Node.js CI / Lint and Test (push) Successful in 1m35s
feat: use data api for products
2025-09-27 14:53:35 -07:00

35 lines
799 B
TypeScript

/**
* @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<Product> {
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;
}
}