diff --git a/examples/00-example-basic/src/api/postAPI.js b/examples/00-example-basic/src/api/postAPI.js index 3831918..259d901 100644 --- a/examples/00-example-basic/src/api/postAPI.js +++ b/examples/00-example-basic/src/api/postAPI.js @@ -1,9 +1,16 @@ import { fetchWithDelay } from './fetch'; const url = 'https://jsonplaceholder.typicode.com/posts'; -const fetchPosts = () => fetchWithDelay(url) - .then((posts) => posts.slice(0, 10)); +const fetchPosts = async () => { +try { + const posts = await fetchWithDealy(url); + const slicedPosts = posts.slice(0, 10); + return slicedPosts + } catch (error) { + throw new Error(error); + } +} export const postAPI = { fetchPosts, -}; \ No newline at end of file +};