Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] getAxiosInstance 필요한 부분 적용 #188

Merged
merged 2 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/apis/templeDetail/axios.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import instance from '@apis/instance';
import { getAxiosInstance } from '@apis/instance';

const getTempleDetails = async (templestayId: string, userId: string) => {
const res = await instance.get('/templestay', {
const getTempleDetails = async (templestayId: string, userId?: string) => {
const axiosInstance = getAxiosInstance();
const res = await axiosInstance.get('/templestay', {
params: { templestayId, userId },
});

Expand Down
2 changes: 1 addition & 1 deletion src/apis/templeDetail/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useQuery } from '@tanstack/react-query';
import getTempleDetails from './axios';
import { TempleDetail } from './type';

const useGetTempleDetails = (templestayId: string, userId: string) => {
const useGetTempleDetails = (templestayId: string, userId?: string) => {
const { data, isLoading, isError } = useQuery<TempleDetail>({
queryKey: ['detailPage', templestayId],
queryFn: () => getTempleDetails(templestayId, userId),
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/pageName/PageName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface PageNameProps {
}

const PageName = ({ title, onRightClick, isLikeBtn = true, isLiked = false }: PageNameProps) => {
const handleToBack = useNavigateTo(-1);
const handleToBack = useNavigateTo('/');

return (
<nav className={PageNameStyle.container}>
Expand Down
5 changes: 4 additions & 1 deletion src/pages/templeDetailPage/TempleDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ const TempleDetailPage = () => {

const userId = localStorage.getItem('userId');
const { templestayId } = useParams();
const { data, isLoading, isError } = useGetTempleDetails(String(templestayId), String(userId));
const { data, isLoading, isError } = useGetTempleDetails(
String(templestayId),
userId || undefined,
);
const queryClient = useQueryClient();

const addWishlistMutation = useAddWishlist();
Expand Down
Loading