diff options
author | Patryk Niedźwiedziński <pniedzwiedzinski19@gmail.com> | 2020-01-29 12:31:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-29 12:31:13 +0100 |
commit | b424c1ce5573f72e36fcca00ef22e4b2f3dde9ff (patch) | |
tree | ff1d1de74e1b165a36d7804a49a3692e6cbea289 /components/Posts/PostList/index.js | |
parent | 13c55f4d5fca3e3452317322e387f75e0690f9c8 (diff) | |
parent | 3e5f329cd8c9692e24f5fd56a5e4189bf2202e0d (diff) | |
download | puszcza-b424c1ce5573f72e36fcca00ef22e4b2f3dde9ff.tar.gz puszcza-b424c1ce5573f72e36fcca00ef22e4b2f3dde9ff.zip |
Merge pull request #27 from 19pdh/develop
Develop
Diffstat (limited to 'components/Posts/PostList/index.js')
-rw-r--r-- | components/Posts/PostList/index.js | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/components/Posts/PostList/index.js b/components/Posts/PostList/index.js index 7e0b1f4..dad805d 100644 --- a/components/Posts/PostList/index.js +++ b/components/Posts/PostList/index.js @@ -1,23 +1,11 @@ import axios from 'axios' -import k from '~/api' +import { apiUrl, parsePosts } from '~/api' import PostList from './PostList' export const getPosts = async () => { - if (process.client) { - let posts = await axios.get(`${window.location.origin}/api/posts.json`) - return parsePosts(posts.data) - } else { - return parsePosts(k.getPosts()) - } + let posts = await axios.get(`${apiUrl}/posts.json`) + return parsePosts(posts.data) } -export const parsePosts = (posts) => - posts.map((post) => ({ - title: post.content.meta.title, - image: post.content.meta.image, - description: post.content.description, - route: post.route, - })) - export default PostList |