Express
-
express async request handler 오류Vue 2021. 1. 26. 17:07
1. sync function의 경우 app.get("/error", (req, res) => { throw "에러" }) 정상적으로 에러를 잡아준다. 2. async function의 경우 app.get("/error", async (req, res) => { throw "에러" }) 에러를 잡아주지 못한다. async function을 try catch문을 사용하여 에러를 잡아주어야한다. app.get("/error", async (req, res, next) => { try { throw "에러" } catch (err) { next(err) } }) 이런식으로 잡아주면 정상적으로 500번대 에러를 잡아준다.
-
vue3 express mongoDB 개발환경 세팅Vue 2020. 12. 29. 18:44
Vue3 설치는 이전 포스팅 참조 Express 로 backend 폴더 설치 npm install -g express-generator express --view=pug backend cd backend npm install npm start 폴더에 app.js 내용 지운 후 다음과같은 코드 작성 또는 backend 폴더 생성 npm init -y npm install express TS 사용하기 src 폴더를 만들고 그 안에 app.ts 생성. 타입스크립트 사용시 모듈을 설치해주어야한다. npm install ts-node npm install -D typescript npm install -D tslint tsc --init 을 통해 tsconfig.json 파일 생성 후 "outDir": "dist..