post 전송 에러 질문드립니다
374
maplestory14191227
投稿した質問数 3
0
index.js
const express = require("express"); //express import
const app = express();
const port = 5006;
const bodyParser = require("body-parser");
const { User } = require("./models/User");
//applicatioin /x-www-form -url encoded
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
const mongoose = require("mongoose");
mongoose
.connect(
"mongodb+srv://euan:abcd1234@boilerplate.tywi2.mongodb.net/?retryWrites=true&w=majority ",
{
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
useFindAndModify: false,
}
)
.then(() => console.log("mongo db is connected.."))
.catch((err) => console.log(err));
app.get("/", (req, res) => {
res.send("Hello World122!");
});
app.post("/register", (req, res) => {
const user = new User(req.body);
user.save((err, userInfo) => {
if (err) return res.json({ success: false, err });
return res.status(200).json({
success: ture,
});
});
});
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
});
user.js
const mongoose = require("mongoose");
const userSchema = mongoose.Schema({
name: {
type: String,
maxlength: 500,
},
email: {
type: String,
trim: true,
unique: 1,
},
password: {
type: String,
minlength: 5,
},
lastname: {
type: String,
maxlength: 50,
},
role: {
type: Number,
default: 0,
},
image: String,
token: {
type: String,
},
tokenExp: {
type: Number,
},
});
const User = mongoose.model("User", userSchema);
module.exports = { User };
------------------------------------------------------------------
{
"success": false,
"err": {
"driver": true,
"name": "MongoError",
"index": 0,
"code": 11000,
"keyPattern": {
"email": 1
},
"keyValue": {
"email": "maplestory1419@gmail.com"
}
}
}
서버확인하였는데 이런식으로 에러가 나옵니다. name에 에러가 있는것 가은데 혼자힘으로 해결이 힘들어 질문드립니다!
감사합니다!
몽고db연결도 확인하였습니다.
자꾸 질문드려서 죄송하네요 ㅠㅠ console 창에도 에러가 없으니 뭐가문제인지 단서를 찾을수가 없습니다 ㅠㅠ
ps강의 정말감사합니다 ㅠ커피라도 대접해드리고싶네용
nodejs
react
回答 3
1
혹시라도 이런 오류가 뜨는분들 보시라고 답글 달아놓을게요
email 속성에 unique가 있어서 뜨는것으로 확인됩니다
회원가입이 되어있는데 또 똑같은 이메일로 회원가입을 해서 뜨는 오류메시지 입니다
깃 이메일이랑 비번이 필요하다고 하네요
0
38
1
404 에러
0
105
1
34강 인증 체크에서 element 사용 때문에 에러나시는 분들 이렇게 하심 됩니다.
0
121
1
로그인, 로그아웃, 토근 작동 안 함
0
242
0
9강 오류 어떻게 해결하나요?
0
195
1
localhost 에서 연결을 거부했습니다.
0
1944
4
포스트맨에서 true가 안떠요
0
152
1
왜 안되나요
0
130
1
몽고db 연결 오류가 납니다 위에껀 입력한 코드, 아래껀 터미널이에요
0
244
1
로그아웃 401 에러(Unauthorized)
0
506
2
암호가 해싱되지 않고 입력값 그대로 db에 저장되는 문제
0
152
1
7강중에서
0
167
2
User.findByToken is not a function
0
214
1
루트 디렉토리
0
275
1
useState
0
564
1
프록시 잘 설정했는데도 404 오류 뜨는 분들
5
879
6
webpack 관련 에러 질문
0
221
1
리액트 관련 질문
0
275
1
14강 로그아웃 안됨
0
319
1
mongoDB 데이터 확인하는 법
0
413
1
postman 에러
0
295
1
선생님 리덕스를 사용하면 어떠한 부분이 좋은지 알 수 있을까요?
0
236
1
다음과 같은 에러들이 발생합니다.
0
277
1
14강 로그아웃 기능 구현시 postman에서 Cannot POST 오류가 뜹니다.
0
380
1

