remove client side post fetch
This commit is contained in:
parent
79a8f498c5
commit
7364eb668b
1 changed files with 5 additions and 24 deletions
|
@ -26,35 +26,16 @@ const Post = ({renderedPost, theme, changeTheme}: PostProps) => {
|
|||
setIsLoading(true);
|
||||
|
||||
if (renderedPost) {
|
||||
console.log('Using Server Side Post');
|
||||
setPost(renderedPost)
|
||||
setIsLoading(false)
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (router.query.id) {
|
||||
const post = await fetch(`/server-api/posts/${router.query.id}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": `Bearer ${Cookies.get("drift-token")}`
|
||||
}
|
||||
})
|
||||
|
||||
if (post.ok) {
|
||||
const res = await post.json()
|
||||
if (res)
|
||||
setPost(res)
|
||||
else
|
||||
setError("Post not found")
|
||||
} else {
|
||||
if (post.status.toString().startsWith("4")) {
|
||||
router.push("/signin")
|
||||
} else {
|
||||
setError(post.statusText)
|
||||
}
|
||||
}
|
||||
setIsLoading(false)
|
||||
if (post.status.toString().startsWith("4")) {
|
||||
router.push("/signin")
|
||||
} else {
|
||||
setError(post.statusText)
|
||||
}
|
||||
}
|
||||
fetchPost()
|
||||
|
|
Loading…
Reference in a new issue