import Post from "../../../models/Posts";
export const rootUrl = 'https://jsonplaceholder.typicode.com';

export const fetchPosts = async (): Promise<Post[]> => {
    const response = await fetch(`${rootUrl}/posts`);
    if (!response.ok) {
        throw new Error('Erreur lors de la récupération des posts');
    }
    const data: Post[] = await response.json();
    return data;
};
