codestates / codestates/triplus

[Error] 데이터베이스에 JSON.stringify로 저장할 땐 [ ], 가져오니 '[~~]'??

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

Description

## 어떤 에러가 발생했나요?
- 데이터베이스에 JSON.stringify 한 데이터를 넣고, 나중에 그 데이터를 JSON.parse 를 하고자 했는데 에러가 났다

### 에러가 발생한 폴더
server > index.js

### 에러 원인
![image](https://user-images.githubusercontent.com/81739782/145273757-8ad868ec-452a-46e1-8990-18364a6c6601.png)

- 파일을 가져오는데 배열이 작은 따옴표로 묶여져서 나오고 있다
- 데이터베이스에 JSON.stringify 하고 데이터에 넣을 때는 작은 따옴표로 감싸지 않은 상태로 들어가 있는데 이게 왜 이렇게 감싸여 있는지 모르겠다. 아무튼, 에러의 원인은 저 작은 따옴표가 있어서 에러가 떴다.

### 에러 해결 방법
![image](https://user-images.githubusercontent.com/81739782/145273970-52918385-65d8-424a-903f-0740e8612517.png)

요거를

![image](https://user-images.githubusercontent.com/81739782/145274003-745f4108-f47b-408d-b67d-60a2729c8cb2.png)

요렇게 가져왔더니 작은 따옴표로 감싸지 않은 배열이 return 됐다

## 에러 해결 관련 링크
- 본인 블로그 링크
https://je-developing.tistory.com/171

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.