diff --git a/FE/src/api/fetchFilterData.js b/FE/src/api/fetchFilterData.js index b443142d1..4846b8e59 100644 --- a/FE/src/api/fetchFilterData.js +++ b/FE/src/api/fetchFilterData.js @@ -11,10 +11,11 @@ const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); * @returns {jsonObject} */ export const fetchLabelsData = async () => { + const accessToken = getAccessToken(); try { const response = await fetch(`${import.meta.env.VITE_TEAM_SERVER}${LABELS_API_URI}`, { headers: { - Authorization: `Bearer ${getAccessToken()}`, + Authorization: `Bearer ${accessToken}`, }, }); if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`); @@ -31,10 +32,11 @@ export const fetchLabelsData = async () => { * @returns {jsonObject} */ export const fetchMembersData = async () => { + const accessToken = getAccessToken(); try { const response = await fetch(`${import.meta.env.VITE_TEAM_SERVER}${MEMBERS_API_URI}`, { headers: { - Authorization: `Bearer ${getAccessToken()}`, + Authorization: `Bearer ${accessToken}`, }, }); if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`); @@ -53,12 +55,13 @@ export const fetchMembersData = async () => { * @returns {jsonObject} */ export const fetchMilestonesData = async (isClosed) => { + const accessToken = getAccessToken(); try { // await delay(5000); const response = await fetch(`${import.meta.env.VITE_TEAM_SERVER}${MILESTONES_API_URI}${isClosed}`, { headers: { - Authorization: `Bearer ${getAccessToken()}`, + Authorization: `Bearer ${accessToken}`, }, }); if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`); @@ -80,7 +83,9 @@ export const fetchMilestonesData = async (isClosed) => { * @param {*String} userId * @returns {jsonObject} */ + export const fetchIssueListData = async (isClosedParam, authorIdParam, assigneeIdParam, labelIdParam, milestoneNameParam, noValuesParam) => { + const accessToken = getAccessToken(); const isClosed = isClosedParam ?? ''; const authorId = authorIdParam ?? ''; const assigneeId = assigneeIdParam ?? ''; @@ -95,7 +100,7 @@ export const fetchIssueListData = async (isClosedParam, authorIdParam, assigneeI }${ISSUE_LIST_API_URI}?isClosed=${isClosed}&authorId=${authorId}&assigneeId=${assigneeId}&labelName=${labelName}&milestoneName=${milestoneNameParam}&noValues=${noValues}`, { headers: { - Authorization: `Bearer ${getAccessToken()}`, + Authorization: `Bearer ${accessToken}`, }, } ); diff --git a/FE/src/api/fetchIssueData.js b/FE/src/api/fetchIssueData.js index f43bbdc83..d9085a469 100644 --- a/FE/src/api/fetchIssueData.js +++ b/FE/src/api/fetchIssueData.js @@ -11,12 +11,12 @@ const ISSUE_DEFAULT_FILE_URI = '/api/files'; */ export const fetchIssueDetailData = async (issueId) => { const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); - + const accessToken = getAccessToken(); try { // await delay(2000); const response = await fetch(`${import.meta.env.VITE_TEAM_SERVER}${ISSUE_DEFAULT_API_URI}/${issueId}`, { headers: { - Authorization: `Bearer ${getAccessToken()}`, + Authorization: `Bearer ${accessToken}`, }, }); if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`); @@ -35,12 +35,13 @@ export const fetchIssueDetailData = async (issueId) => { * @returns {} */ export const fetchIssueStateToggle = async (toIssueState, issueIds) => { + const accessToken = getAccessToken(); try { const response = await fetch(`${import.meta.env.VITE_TEAM_SERVER}${ISSUE_DEFAULT_API_URI}/${toIssueState ? 'close' : 'open'}`, { method: 'POST', headers: { 'Content-Type': 'application/json', - 'Authorization': `Bearer ${getAccessToken()}`, + 'Authorization': `Bearer ${accessToken}`, }, body: JSON.stringify({ issueIds }), }); @@ -66,12 +67,13 @@ export const fetchIssueStateToggle = async (toIssueState, issueIds) => { */ export const fetchDeleteIssue = async (issueId) => { + const accessToken = getAccessToken(); try { const response = await fetch(`${import.meta.env.VITE_TEAM_SERVER}${ISSUE_DEFAULT_API_URI}/${issueId}`, { method: 'DELETE', headers: { 'Content-Type': 'application/json', - 'Authorization': `Bearer ${getAccessToken()}`, + 'Authorization': `Bearer ${accessToken}`, }, }); @@ -97,12 +99,13 @@ export const fetchDeleteIssue = async (issueId) => { - 서버 내부 오류시: 500 */ export const fetchModifyIssueTitle = async (title, issueId) => { + const accessToken = getAccessToken(); try { const response = await fetch(`${import.meta.env.VITE_TEAM_SERVER}${ISSUE_DEFAULT_API_URI}/${issueId}/title`, { method: 'PATCH', headers: { 'Content-Type': 'application/json', - 'Authorization': `Bearer ${getAccessToken()}`, + 'Authorization': `Bearer ${accessToken}`, }, body: JSON.stringify({ title }), }); @@ -129,12 +132,13 @@ export const fetchModifyIssueTitle = async (title, issueId) => { - 서버 내부 오류시: 500 */ export const fetchModifyIssueContent = async (content, fileId, issueId) => { + const accessToken = getAccessToken(); try { const response = await fetch(`${import.meta.env.VITE_TEAM_SERVER}${ISSUE_DEFAULT_API_URI}/${issueId}/body`, { method: 'PATCH', headers: { 'Content-Type': 'application/json', - 'Authorization': `Bearer ${getAccessToken()}`, + 'Authorization': `Bearer ${accessToken}`, }, body: JSON.stringify({ content, fileId }), }); @@ -161,12 +165,13 @@ export const fetchModifyIssueContent = async (content, fileId, issueId) => { - 서버 내부 오류시: 500 */ export const fetchModifyIssueComment = async (content, fileId, commentId) => { + const accessToken = getAccessToken(); try { const response = await fetch(`${import.meta.env.VITE_TEAM_SERVER}${ISSUE_COMMENTS_DEFAULT_API_URI}/${commentId}`, { method: 'PUT', headers: { 'Content-Type': 'application/json', - 'Authorization': `Bearer ${getAccessToken()}`, + 'Authorization': `Bearer ${accessToken}`, }, body: JSON.stringify({ content, fileId }), }); @@ -194,12 +199,13 @@ export const fetchModifyIssueComment = async (content, fileId, commentId) => { - 서버 내부 오류시: 500 */ export const fetchCreateIssueComment = async (writerId, content, issueId, fileId) => { + const accessToken = getAccessToken(); try { const response = await fetch(`${import.meta.env.VITE_TEAM_SERVER}${ISSUE_COMMENTS_DEFAULT_API_URI}`, { method: 'POST', headers: { 'Content-Type': 'application/json', - 'Authorization': `Bearer ${getAccessToken()}`, + 'Authorization': `Bearer ${accessToken}`, }, body: JSON.stringify({ writerId, content, issueId, fileId }), }); @@ -225,12 +231,13 @@ export const fetchCreateIssueComment = async (writerId, content, issueId, fileId - 서버 내부 오류시: 500 */ export const fetchDeleteComment = async (commentId) => { + const accessToken = getAccessToken(); try { const response = await fetch(`${import.meta.env.VITE_TEAM_SERVER}${ISSUE_COMMENTS_DEFAULT_API_URI}/${commentId}`, { method: 'DELETE', headers: { 'Content-Type': 'application/json', - 'Authorization': `Bearer ${getAccessToken()}`, + 'Authorization': `Bearer ${accessToken}`, }, }); @@ -256,12 +263,13 @@ export const fetchDeleteComment = async (commentId) => { - 서버 내부 오류시: 500 */ export const fetchModifyIssueLabels = async (issueId, labelIds) => { + const accessToken = getAccessToken(); try { const response = await fetch(`${import.meta.env.VITE_TEAM_SERVER}${ISSUE_DEFAULT_API_URI}/${issueId}/label`, { method: 'PATCH', headers: { 'Content-Type': 'application/json', - 'Authorization': `Bearer ${getAccessToken()}`, + 'Authorization': `Bearer ${accessToken}`, }, body: JSON.stringify({ labelIds }), }); @@ -288,12 +296,13 @@ export const fetchModifyIssueLabels = async (issueId, labelIds) => { - 서버 내부 오류시: 500 */ export const fetchModifyIssueAssignees = async (issueId, assigneeIds) => { + const accessToken = getAccessToken(); try { const response = await fetch(`${import.meta.env.VITE_TEAM_SERVER}${ISSUE_DEFAULT_API_URI}/${issueId}/assignee`, { method: 'PATCH', headers: { 'Content-Type': 'application/json', - 'Authorization': `Bearer ${getAccessToken()}`, + 'Authorization': `Bearer ${accessToken}`, }, body: JSON.stringify({ assigneeIds }), }); @@ -320,12 +329,13 @@ export const fetchModifyIssueAssignees = async (issueId, assigneeIds) => { - 서버 내부 오류시: 500 */ export const fetchModifyIssueMilestone = async (issueId, milestoneId) => { + const accessToken = getAccessToken(); try { const response = await fetch(`${import.meta.env.VITE_TEAM_SERVER}${ISSUE_DEFAULT_API_URI}/${issueId}/milestone`, { method: 'PATCH', headers: { 'Content-Type': 'application/json', - 'Authorization': `Bearer ${getAccessToken()}`, + 'Authorization': `Bearer ${accessToken}`, }, body: JSON.stringify({ milestoneId }), }); @@ -352,11 +362,12 @@ export const fetchModifyIssueMilestone = async (issueId, milestoneId) => { */ //TODO: 파일 형식 미지원 시 에러 처리 export const fetchUploadFile = async (formData) => { + const accessToken = getAccessToken(); try { const response = await fetch(`${import.meta.env.VITE_TEAM_SERVER}${ISSUE_DEFAULT_FILE_URI}`, { method: 'POST', headers: { - Authorization: `Bearer ${getAccessToken()}`, + Authorization: `Bearer ${accessToken}`, }, body: formData, }); @@ -386,13 +397,14 @@ export const fetchUploadFile = async (formData) => { - 서버 내부 오류시: 500 */ export const fetchCreateNewIssue = async (title, content, authorId, milestoneId, fileIdParam, labelIds, assigneeIds) => { + const accessToken = getAccessToken(); const fileId = fileIdParam || null; try { const response = await fetch(`${import.meta.env.VITE_TEAM_SERVER}${ISSUE_DEFAULT_API_URI}`, { method: 'POST', headers: { 'Content-Type': 'application/json', - 'Authorization': `Bearer ${getAccessToken()}`, + 'Authorization': `Bearer ${accessToken}`, }, body: JSON.stringify({ title, content, authorId, milestoneId, fileId, labelIds, assigneeIds }), }); diff --git a/FE/src/api/fetchLabelData.js b/FE/src/api/fetchLabelData.js index 0bb5dae08..6143297ad 100644 --- a/FE/src/api/fetchLabelData.js +++ b/FE/src/api/fetchLabelData.js @@ -12,11 +12,12 @@ const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); * - 성공: 200 */ export const fetchLabelMilestoneCountData = async () => { + const accessToken = getAccessToken(); try { // await delay(2000); const response = await fetch(`${import.meta.env.VITE_TEAM_SERVER}${HOME_DEFAULT_API_URI}`, { headers: { - Authorization: `Bearer ${getAccessToken()}`, + Authorization: `Bearer ${accessToken}`, }, }); if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`); @@ -34,9 +35,14 @@ export const fetchLabelMilestoneCountData = async () => { * @returns {jsonObject} */ export const fetchLabelDetailData = async () => { + const accessToken = getAccessToken(); try { // await delay(2000); - const response = await fetch(`${import.meta.env.VITE_TEAM_SERVER}${LABEL_DEFAULT_API_URI}`); + const response = await fetch(`${import.meta.env.VITE_TEAM_SERVER}${LABEL_DEFAULT_API_URI}`, { + headers: { + Authorization: `Bearer ${accessToken}`, + }, + }); if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`); if (response.status === 200 || response.status === 201) { @@ -61,12 +67,14 @@ export const fetchLabelDetailData = async () => { - 존재하지 않는 라벨 아이디: 404 */ export const fetchModifyLabel = async (name, descriptionParam, textColor, bgColor, labelId) => { + const accessToken = getAccessToken(); const description = descriptionParam || null; try { const response = await fetch(`${import.meta.env.VITE_TEAM_SERVER}${LABEL_DEFAULT_API_URI}/${labelId}`, { method: 'PUT', headers: { 'Content-Type': 'application/json', + 'Authorization': `Bearer ${accessToken}`, }, body: JSON.stringify({ name, description, textColor, bgColor }), }); @@ -94,11 +102,13 @@ export const fetchModifyLabel = async (name, descriptionParam, textColor, bgColo - 존재하지 않는 라벨 아이디: 404 */ export const fetchDeleteLabel = async (labelId) => { + const accessToken = getAccessToken(); try { const response = await fetch(`${import.meta.env.VITE_TEAM_SERVER}${LABEL_DEFAULT_API_URI}/${labelId}`, { method: 'DELETE', headers: { 'Content-Type': 'application/json', + 'Authorization': `Bearer ${accessToken}`, }, }); @@ -126,12 +136,14 @@ export const fetchDeleteLabel = async (labelId) => { - 라벨 이름 중복: 409 */ export const fetchCreateNewLabel = async (name, descriptionParam, textColor, bgColor) => { + const accessToken = getAccessToken(); const description = descriptionParam || null; try { const response = await fetch(`${import.meta.env.VITE_TEAM_SERVER}${LABEL_DEFAULT_API_URI}`, { method: 'POST', headers: { 'Content-Type': 'application/json', + 'Authorization': `Bearer ${accessToken}`, }, body: JSON.stringify({ name, description, textColor, bgColor }), });