이건 Python이 잘못했다다
This commit is contained in:
parent
2d2e546673
commit
ca946990e1
41 changed files with 3081 additions and 964 deletions
25
app/lib/meal.ts
Normal file
25
app/lib/meal.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
const KEY = process.env.NEIS_API_KEY;
|
||||
|
||||
export function removeNutritionInfo(value: string): string {
|
||||
const lines = value.trim().split('\n');
|
||||
const cleanedLines = lines.map(line => line.replace(/\(.*?\)/g, '').trim());
|
||||
const result = cleanedLines.join('\n');
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function getMealInfo(MLSV_YMD: string): Promise<{ meal: string; date: string, kcal: string }> {
|
||||
const url = `https://open.neis.go.kr/hub/mealServiceDietInfo?Type=json&ATPT_OFCDC_SC_CODE=E10&SD_SCHUL_CODE=7331071&MLSV_YMD=${MLSV_YMD}&KEY=${KEY}`;
|
||||
const response = await fetch(url);
|
||||
const data = await response.json();
|
||||
// @ts-ignore
|
||||
const DDISH_NM = data.mealServiceDietInfo[1].row[0].DDISH_NM;
|
||||
return {
|
||||
meal: removeNutritionInfo(DDISH_NM.replace(/<br\s*\/?>/gi, '\n')),
|
||||
date: MLSV_YMD,
|
||||
// @ts-ignore
|
||||
|
||||
kcal: data.mealServiceDietInfo[1].row[0].CAL_INFO,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue