codestates / codestates/AllForYou
[Error] 남태식 / 2022-01-12
- Dominant language
- JavaScript
- Stars
- 0
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
### 어떤 에러인가요?
* 서버 연결시 주소 및 엔드포인트 에러
### 에러 메시지


### 에러 핸들링 방법
* localhost:4000을 localhost:80으로 변경
* 서버쪽 코드 변경 (contentsAll.js)
```
const { contents, likes } = require("../../models");
module.exports = async (req, res) => {
try {
const contentsData = await contents.findAll({
attributes: [
"id",
"title",
"image",
"category",
"type",
"director",
"link",
"runtime",
"summary",
"year",
"genres"
],
include: [
{ model: likes, attributes: ["id"] }
]
})
// console.log(contentsData)
let contentsList = contentsData.map((el) => {
return {
"id": el.id,
"title": el.title,
"category": el.category,
"like": el.likes.length,
"image": el.image,
"type": el.type,
"director": el.director,
"link": el.link,
"runtime": el.runtime,
"summary": el.summary,
"year": el.year,
"genres": el.genres
}
})
console.log(contentsList)
return res.status(200).json({ data: contentsList, message: "successfully contents show all" })
}
catch (err) {
return res.status(500).json({ data: null, message: "server error" })
}
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.