-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
43 additions
and
17 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
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,12 @@ | ||
'use client' | ||
|
||
import { useMutation } from '@tanstack/react-query' | ||
import { postFcmToken } from '.' | ||
|
||
export const usePostFcmToken = () => { | ||
return useMutation({ | ||
mutationFn: async (fcmToken: string) => postFcmToken({ fcmToken }), | ||
// eslint-disable-next-line no-console | ||
onSuccess: () => console.log('토큰 전송 성공'), | ||
}) | ||
} |
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,23 @@ | ||
'use server' | ||
|
||
import { auth } from '@/app/api/auth/[...nextauth]/auth' | ||
import { API_ENDPOINTS } from '@/shared/configs/endpoint' | ||
import { http } from '@/shared/lib/axios/http' | ||
|
||
export const postFcmToken = async (requestBody: { fcmToken: string }) => { | ||
try { | ||
const session = await auth() | ||
|
||
const response = await http.post(API_ENDPOINTS.FCM.POST.TOKEN, requestBody, { | ||
headers: { | ||
Authorization: `Bearer ${session?.user.accessToken}`, | ||
}, | ||
}) | ||
|
||
// eslint-disable-next-line no-console | ||
console.log(response) // 디버깅용 | ||
} catch (error) { | ||
console.error(error) | ||
throw error | ||
} | ||
} |
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