Skip to content

Commit

Permalink
Merge pull request #100 from hyeyeong-nam/520
Browse files Browse the repository at this point in the history
520
  • Loading branch information
hyeyeong-nam authored May 21, 2024
2 parents f1e6ec7 + 8a64d67 commit b8b91f3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
4 changes: 2 additions & 2 deletions front/src/components/PostPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function PostPage() {
useEffect(() => {
if (postId) {
// postId를 사용하여 해당 글의 정보를 가져옴
fetch(`http://localhost:8080/api/postpage/${postId}`)
fetch(`/api/postpage/${postId}`)
.then(res => res.json())
.then(json => {
// 데이터가 있을 경우 해당 데이터를 적절히 처리하여 state에 저장
Expand Down Expand Up @@ -98,7 +98,7 @@ function PostPage() {
//수정하는 경우 기존 포스트를 삭제하고 새로 포스트 아이디를 발급함.
//아이디를 현재 시간을 기준으로 하기 때문.
if (postId) {
fetch(`http://localhost:8080/api/post/${postId}`, {
fetch(`/api/post/${postId}`, {
method: 'DELETE'
})
.then(res => res.json())
Expand Down
19 changes: 2 additions & 17 deletions front/src/components/PostViewPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ function PostViewPage() {
const [_li, set_Li] = useState([]);
const [bookInfoContainerDisplay, setbookInfoContainerDisplay] = useState("none");
const [buttonDisplay, setButtonDisplay] = useState("block");
const [bookData, setBookData] = useState({});
const UID = (localStorage.getItem('UID')) == null ? 'null' : localStorage.getItem('UID');
const navigate = useNavigate();
const [selectedBody,setSelectedBody]=useState({body:""});
Expand All @@ -21,7 +20,7 @@ function PostViewPage() {
changeBlurBoxState();//blurBox state변경
set_Li([]); // postId가 변경될 때마다 _li 상태 초기화
if (postId) { // postID가 존재하는 경우에만 fetch 요청 보냄
fetch(`http://localhost:8080/api/post/${postId}`, {
fetch(`/api/post/${postId}`, {
method: "POST",
headers: {
'Content-Type': 'application/json'
Expand Down Expand Up @@ -81,7 +80,7 @@ function PostViewPage() {

function handleDelete() {
if (postId) {
fetch(`http://localhost:8080/api/post/${postId}`, {
fetch(`/api/post/${postId}`, {
method: 'DELETE',
})
.then(res => {
Expand All @@ -96,20 +95,6 @@ function PostViewPage() {
}
}


function fetchBookInfo(isbn) {
if (isbn) {
fetch(`http://localhost:8080/api/books/search/${isbn}`)
.then(res => res.json())
.then(json => {
console.log("bookData:", json);
setBookData(json[0]);
})
.catch(error => console.log(error));
}
}


return (
<>
<article>
Expand Down

0 comments on commit b8b91f3

Please sign in to comment.