Fixing infinite scroll
This commit is contained in:
parent
755aed62c6
commit
b59456505a
2 changed files with 56 additions and 14 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue