Working initial version
This commit is contained in:
23
frontend/src/lib/api.ts
Normal file
23
frontend/src/lib/api.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
const API_URL = import.meta.env.VITE_API_URL;
|
||||
|
||||
async function getArticle(
|
||||
celexId: string,
|
||||
article: number,
|
||||
language: string
|
||||
): Promise<string> {
|
||||
console.debug(
|
||||
`Fetching article ${article} for CELEX ID ${celexId} in ${language} language`
|
||||
);
|
||||
const response = await fetch(
|
||||
`${API_URL}/${celexId}/articles/${article}/${language}`
|
||||
);
|
||||
return await response.text();
|
||||
}
|
||||
|
||||
async function getArticleIds(celexId: string): Promise<number[]> {
|
||||
console.debug(`Fetching article list for CELEX ID ${celexId}`);
|
||||
const response = await fetch(`${API_URL}/${celexId}/articles`);
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
export { getArticle, getArticleIds };
|
||||
Reference in New Issue
Block a user