File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change 11import Papa from "papaparse" ;
22import type { Award , Member } from "@/types/types" ;
33
4- async function fetchCSV < T > ( url : string ) : Promise < T [ ] > {
4+ async function fetchCSV < T > ( url : string ) : Promise < { data : T [ ] ; fetchedAt : Date } > {
55 const res = await fetch ( url , { next : { revalidate : 60 } } ) ;
66 const text = await res . text ( ) ;
77 const { data } = Papa . parse < T > ( text , { header : true , skipEmptyLines : true } ) ;
8- return data ;
8+ return { data, fetchedAt : new Date ( ) } ;
99}
1010
1111export async function getAwards ( ) {
12- const data = await fetchCSV < Award > ( process . env . AWARDS_CSV_URL ! ) ;
13- return data . filter ( ( row ) => row . 내용 ?. trim ( ) ) ;
12+ const { data, fetchedAt } = await fetchCSV < Award > ( process . env . AWARDS_CSV_URL ! ) ;
13+ return { data : data . filter ( ( row ) => row . 내용 ?. trim ( ) ) , fetchedAt } ;
1414}
1515
1616export async function getMembers ( ) {
17- const data = await fetchCSV < Member > ( process . env . MEMBERS_CSV_URL ! ) ;
18- return data . filter ( ( row ) => row . 이름 ?. trim ( ) ) ;
17+ const { data, fetchedAt } = await fetchCSV < Member > ( process . env . MEMBERS_CSV_URL ! ) ;
18+ return { data : data . filter ( ( row ) => row . 이름 ?. trim ( ) ) , fetchedAt } ;
1919}
You can’t perform that action at this time.
0 commit comments