From f43fc22c4927ac43e71d9acd506cfd02fede2f2e Mon Sep 17 00:00:00 2001 From: Justine Ouellette <justine.ouellette@polymtl.ca> Date: Sun, 5 Feb 2023 04:39:01 -0500 Subject: [PATCH] get only one thing wow --- assets/APIService.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/assets/APIService.ts b/assets/APIService.ts index eb899d3..1e63004 100644 --- a/assets/APIService.ts +++ b/assets/APIService.ts @@ -21,7 +21,7 @@ class APIService { } // returns a list of all transacations - async read(): Promise<Transaction[]> { + async list(): Promise<Transaction[]> { let response = await fetch('/api/transaction'); let result = await response.json() as Transaction[]; return result; @@ -38,11 +38,17 @@ class APIService { // delete a particular transaction async delete(id: number) { - let response = await fetch(`/api/transaction/${id}`, + await fetch(`/api/transaction/${id}`, { method: 'DELETE', }); } + + async get(id: number): Promise<Transaction> { + let response = await fetch(`/api/transaction/${id}`); + let result = await response.json() as Transaction; + return result; + } } -- GitLab