CoastalCommitsPastes/client/components/my-posts/index.tsx

18 lines
465 B
TypeScript
Raw Normal View History

2022-03-06 19:46:59 -05:00
import useSWR from "swr"
import PostList from "../post-list"
2022-03-15 15:15:54 -04:00
import Cookies from "js-cookie"
2022-03-06 19:46:59 -05:00
const fetcher = (url: string) => fetch(url, {
headers: {
'Content-Type': 'application/json',
2022-03-15 15:15:54 -04:00
'Authorization': `Bearer ${Cookies.get("drift-token")}`
2022-03-06 19:46:59 -05:00
},
}).then(r => r.json())
const MyPosts = () => {
const { data, error } = useSWR('/server-api/users/mine', fetcher)
2022-03-06 19:46:59 -05:00
return <PostList posts={data} error={error} />
}
export default MyPosts