-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
63 additions
and
69 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,55 @@ | ||
import {privateAxios} from "../utils/customAxios"; | ||
import { privateAxios } from "../utils/customAxios"; | ||
|
||
/*---- 게시글 등록 ----*/ | ||
export const postJobPosting = async (payload) => { | ||
|
||
const endpoint = `/api/v1/post`; | ||
const response = { | ||
isSuccess: false, | ||
message: "", | ||
data: null, | ||
}; | ||
|
||
try { | ||
const result = await privateAxios.post(endpoint, payload); | ||
return { | ||
isSuccess: true, | ||
message: result.data.message, | ||
postId: result.data.postId, | ||
}; | ||
const result = await privateAxios.get("/api/v1/post", { | ||
params: payload, | ||
}); | ||
|
||
if (result.status === 200) { | ||
response.isSuccess = true; | ||
response.message = result.data.message; | ||
response.data = result.data.data; | ||
} | ||
} catch (error) { | ||
return { | ||
isSuccess: false, | ||
message: error.response?.data?.message || "API 요청 실패", | ||
}; | ||
response.isSuccess = false; | ||
response.message = | ||
error.response?.status === 404 | ||
? "존재하지 않는 유저입니다." | ||
: error.response?.status === 400 | ||
? "정의되지 않은 유저입니다." | ||
: error.response?.data?.message || error.message; | ||
} | ||
|
||
return response; | ||
}; | ||
|
||
/*---- 게시글 수정 ----*/ | ||
export const updateJobPosting = async (payload) => { | ||
const endpoint = `api/v1/post/update`; | ||
const response = { | ||
isSuccess: false, | ||
message: "", | ||
}; | ||
|
||
try { | ||
const result = await privateAxios.post(endpoint, payload); | ||
return { | ||
isSuccess: true, | ||
message: result.data.message, | ||
}; | ||
const result = await privateAxios.patch("/{postId}", payload); | ||
|
||
if (result.status === 200) { | ||
response.isSuccess = true; | ||
response.message = result.data.message; | ||
} | ||
} catch (error) { | ||
return { | ||
isSuccess: false, | ||
message: error.response?.data?.message || "API 요청 실패", | ||
}; | ||
response.isSuccess = false; | ||
response.message = | ||
error.response?.data?.message || "API 요청 실패"; | ||
} | ||
|
||
return response; | ||
}; |
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