codestates / codestates/AllForYou

[Error] 남태식 / 2022-01-12

Open
#117 0 comments 0 reactions 0 assignees View on GitHub
complete Err
Dominant language
JavaScript
Stars
0
Forks
4
PR merge metrics
No merged PRs in 30d

Description

### 어떤 에러인가요?
* 서버 연결시 주소 및 엔드포인트 에러

### 에러 메시지
![스크린샷 2022-01-12 오전 11 57 25](https://user-images.githubusercontent.com/83868259/149132194-4421fcaf-8adf-46f7-af7c-bd6cae76e3d4.png)

![스크린샷 2022-01-12 오후 2 15 26](https://user-images.githubusercontent.com/83868259/149132230-c86183c0-5514-4e64-b34e-d42bd01ec6ed.png)

### 에러 핸들링 방법
* 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.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.