Skip to content

Commit

Permalink
πŸ›fix: RelatedKeyword.js - μ—λŸ¬ λ°œμƒ μ‹œ λΆ€λͺ¨λ‘œ μ—λŸ¬ throw ν•˜λ„λ‘ μˆ˜μ •
Browse files Browse the repository at this point in the history
  • Loading branch information
ShinHeeEul committed Jun 25, 2024
1 parent 71c109a commit 85e2729
Showing 1 changed file with 22 additions and 39 deletions.
61 changes: 22 additions & 39 deletions src/lib/apis/RelatedKeyword.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,32 @@ import axios from "axios";

const BASE_URL = "/api/keyword";
const service = axios.create({
baseURL: BASE_URL,
})
baseURL: BASE_URL,
});

//1. μ—°κ΄€ν‚€μ›Œλ“œ κ°€μ Έμ˜€κΈ°
export async function relatedKeywordAPI({keyword}) {
try {
const resp = await service.post("/",{
keyword: keyword,
})

;
export async function relatedKeywordAPI({ keyword }) {
try {
const resp = await service.post("/", {
keyword: keyword,
});
return resp.data;

} catch(error) {
if (!keyword) {
return res.status(400).json({ error: 'keyword is required' });
}
else {
return false;
}
}
};

} catch (error) {
throw error;
}
}

//2. 검색어-μ—°κ΄€ν‚€μ›Œλ“œ κ΄€λ ¨ λ‰΄μŠ€ κ°€μ Έμ˜€κΈ°
export async function relatedNewsAPI({exWord, keyword}) {
try {
console.log("FE->BE μ—°κ΄€ν‚€μ›Œλ“œ API μš”μ²­ μˆ˜ν–‰")

const resp = await service.post("/news",{
exWord: exWord,
keyword: keyword,
})
;
export async function relatedNewsAPI({ exWord, keyword }) {
try {
console.log("FE->BE μ—°κ΄€ν‚€μ›Œλ“œ API μš”μ²­ μˆ˜ν–‰");

const resp = await service.post("/news", {
exWord: exWord,
keyword: keyword,
});
return resp.data;

} catch(error) {
if (!exWord || !keyword) {
return res.status(400).json({ error: 'exWord and keyword are required' });
}
else {
return false;
}
} catch (error) {
throw error;
}
}
};

0 comments on commit 85e2729

Please sign in to comment.