generated from nhcarrigan/template
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user