This repository has been archived by the owner on Jan 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
68 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import views from '../views/detail/detail.html' | ||
import Axios from 'axios'; | ||
|
||
export default () => { | ||
const divElement = document.createElement('div'); | ||
divElement.classList = "detail-section"; | ||
divElement.innerHTML = views; | ||
|
||
const postId = localStorage.getItem('postId'); | ||
const API_URL = 'http://43.201.103.199/post/' + postId; | ||
|
||
Axios.get(API_URL).then((res) => { | ||
console.log(res.data.data) | ||
let detail = res.data.data; | ||
|
||
divElement.querySelector("#detail-img").innerHTML = ` | ||
<img src=${detail.post.image} style="width: 200px" /> | ||
` | ||
divElement.querySelector("#detail-title").innerHTML = ` | ||
${detail.post.title} | ||
` | ||
divElement.querySelector("#detail-date").innerHTML = ` | ||
${detail.post.updatedAt.substr(0,9)} | ||
` | ||
divElement.querySelector("#detail-desc").innerHTML = ` | ||
${detail.post.content} | ||
` | ||
|
||
detail.comments.forEach((el) => { | ||
divElement.querySelector("#detail-comment").innerHTML += ` | ||
댓글 ::: ${el.content} <br> | ||
` | ||
}) | ||
|
||
|
||
}) | ||
|
||
return divElement; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
async function delDetail() { | ||
let postId = localStorage.getItem("postId") | ||
const res = await fetch("http://43.201.103.199/post/" + postId, { | ||
method: "DELETE", | ||
}) | ||
location.href = "#/" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<div id="detail-img"> | ||
|
||
</div> | ||
<div id="detail-post"> | ||
<div id="detail-title"></div> | ||
<div id="detail-date"></div> | ||
<div id="detail-desc"></div> | ||
</div> | ||
|
||
<div id="detail-comment"> | ||
|
||
</div> | ||
<hr> | ||
<div id="detail-control"> | ||
<div id="detail-fix">수정하기</div> | ||
<div id="detail-delete" onClick="delDetail()">삭제하기</div> | ||
</div> |
Empty file.