Fixing infinite scroll

This commit is contained in:
Imbus 2023-12-14 23:14:33 +01:00
parent 755aed62c6
commit b59456505a
2 changed files with 56 additions and 14 deletions

View file

@ -56,6 +56,12 @@ export async function getPosts(): Promise<Post[]> {
return data;
}
export async function getPostsInterval(offset: number, limit: number): Promise<Post[]> {
const res = await fetch(URL + `/api/posts?offset=${offset}&limit=${limit}`);
const data = await res.json();
return data;
}
/**
* Fetches a specific post by its ID from the API.
* @async
@ -63,7 +69,7 @@ export async function getPosts(): Promise<Post[]> {
* @param {string} id - The ID of the post to fetch.
* @returns {Promise<Post>} A promise that resolves to the requested post.
*/
export async function getPost(id: string): Promise<Post> {
export async function getPost(id: number): Promise<Post> {
const res = await fetch(URL + `/api/posts/${id}`);
const data = await res.json();
return data;