Skip to content

Commit

Permalink
[#31] orderDetial 페이지 axios 요청 시 헤더에 토큰 값을 넣어서 요청하도록 수정
Browse files Browse the repository at this point in the history
orderDetial 페이지 axios 요청 시 헤더에 토큰 값을 넣어서 요청하도록 수정
  • Loading branch information
Joonhyung-Choi committed Mar 27, 2023
1 parent e7b8319 commit b791aad
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pages/orderDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,21 @@ import axios from "axios";
import { useEffect, useState } from "react";

export default function OrderDetail() {
// 토큰값은 로그인 할때마다 갱신해주기
const TOKEN =
"eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ3bnNndWRkbDU3M0BuYXZlci5jb20iLCJyb2xlIjoiVVNFUiIsImV4cCI6MTY3OTkyNDc0N30.QmDIr7NG3-CtxOm3vzWZ46rbDhNNitd4L2ewr70qCGE";
const router = useRouter();
const id = router.query.id;
const [detailDataState, setDetailDataState] = useState<any>();
const getDetailData = async () => {
try {
const response = await axios.get(
`http://localhost:8080/orders/detail/${id}`
`http://localhost:8080/orders/detail/${id}`,
{
headers: {
Authorization: `${TOKEN}`,
},
}
);
console.log(response.data);
setDetailDataState(response.data);
Expand Down

0 comments on commit b791aad

Please sign in to comment.