about summary refs log tree commit diff
path: root/components/Posts/PostList/index.js
blob: 2b8ad928b543a229af6dd8099626fff9616df2c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import axios from 'axios'

import k from '~/api'
import PostList from './PostList'

export const getPosts = async () => {
  let posts = await axios.get(
    `https://feature-json-api--puszcza.netlify.com/api/posts.json`
  )
  return parsePosts(posts.data)
}

export const parsePosts = (posts) =>
  posts.map((post) => ({
    title: post.title,
    image: post.image,
    description: post.description,
    route: post.path,
    meta: post.meta,
  }))

export default PostList