๐ Today I Learned
- ํ๋ฃจ์ข ์ผ Aniverse API ์์ฑ ํ ์ฐ๊ฒฐ
๐ข Today's error
![1109-1](https://user-images.githubusercontent.com/77181984/142041402-44ce2ea8-e862-492c-ab50-944fb9f8ed14.png)
DB ์ธ๋ํค ์ ์ฝ์กฐ๊ฑด์ ์๋ฐํ์ฌ ์๊ธฐ๋ ์๋ฌ์ธ๋ฐ, ํ ์ด๋ธ๋ค์ ๊ด๊ณ๋ฅผ ์๊ฐํ์ง ์๊ณ ๊ฐ๋ค์ ํ๊บผ๋ฒ์ insertํด์ ์๊ธฐ๋ ๋ฌธ์ ์ด๋ค. post API๋ฅผ ์ค๊ณํ ๋ ์ ๋ณด๋ค์ด DB์ ๋ค์ด๊ฐ๋ ์์์ ํ ์ด๋ธ๊ฐ์ join๊ด๊ณ๋ฅผ ๊ณ ๋ คํ์ฌ insert์ฟผ๋ฆฌ๋ฅผ ๋๋์ด์ฃผ์ด์ผ ํ๋ค.
- adoptController
exports.postAdoptUserInfo = async function (req, res) {
const {animalIdx, userIdx, contactName, contactPhoneNum, adoptComment} = req.body;
try{
var adoptListIdx = await adoptModel.selectAdoptListIdx(animalIdx);
const postAdoptInfo = await adoptModel.insertAdoptRequestInfo(
adoptListIdx, userIdx, contactName, contactPhoneNum, adoptComment
);
res.json({
isSuccess: true
});
} catch (err){
logger.error(`postAdoptUserInfo DB Connection error\n: ${err.message}`);
return res.status(500).send(`Error: ${err.message}`);
}
};
- animalIdx๋ก adoptListIdx ๋ฝ์์ค๊ธฐ
- ๋ฝ์ adoptList๋ฅผ ๋ค๋ฅธ ๊ฐ๋ค๊ณผ ํจ๊ป insertAdoptRequestInfo ์ฟผ๋ฆฌ์ ๋ ๋ ค์ฃผ๊ธฐ
๐ Comment
- API ํ๋ ์ ์ฉ์ํฌ ๋ ๋ง๋ค postman์์ ์คํ์์ผ๋ณด๋ฉด์ ๊ณ์ ์๋ฌ๊ณ ์น๊ธฐ
- ํ๋ก ํธ์ API ํ๋ ์ฐ๊ฒฐํ ๋ ๋ง๋ค ๋ฐ์ํ๋ ์๋ฌ๊ณ ์น๊ธฐ
์ธ์ ์ฏค ๊ผผ๊ผผํด์ง ์ ์์๊นใ
postman์์๋ ์๋ง ์ฃผ๊ณ ๋ฐ๋ ๊ฐ๋ค์ด ํ๋ก ํธ์ ์ฐ๊ฒฐ๋งํ๋ฉด undefined๊ฐ ๋์ด๋ฒ๋ฆฌ๋ ํ๋ก ํธ๋ ๋ฐฑ์๋๋ ๋งค์ฐ ์คํธ๋ ์ค๋ค. ์ปค๋ฎค๋์ผ์ด์ ์ด ์ ๊ฐ๋ฐ์๋ค์ ์ค์ํ ์ญ๋์ด๋ผ๊ณ ํ๋์ง ๋ผ์ ๋ฆฌ๊ฒ ๋๋ผ๋ ์ค์ด๋ค๐ญ๐ญ
'TIL' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[TIL] 2022-01-12 (3) | 2022.01.13 |
---|---|
[TIL] 2021-10-11 (7) | 2021.10.12 |
[TIL] 2021-10-09 (2) | 2021.10.10 |