moonjong938083
@moonjong938083
Reviews Written
-
Average Rating
-
Posts
Q&A
404 ์๋ฌ๊ฐ ๋ ์ ์ง๋ฌธ๋๋ฆฝ๋๋ค
์ ์ ๋ก์ด๋ ํด๊ฒฐํ์ต๋๋ค!! router/user.js์ ์ฐ๊ฒฐ์ด ์๋ชป๋์์์ต๋๋ค ์ข์ ๊ฐ์ ํญ์ ๊ฐ์ฌํฉ๋๋ค
- 0
- 1
- 181
Q&A
ํ๋ก์ฐ ํ๋ก์ ๊ด๊ณ๊ฐ ์๋ํ์ง ์์ต๋๋คใ
์์ด๋ 1๋ก 2 3 4 5 6๊น์ง ๋ชจ๋ ํ๋ก์ ํํ์ ๋ก๊ทธ์ธ์ ํ๋ฉด (์ฌ์ง) ์ด๋ ๊ฒ ์ฝ์์ฐ์ด๋ณด๋ฉด ๋น๋๋ค. ์ด๊ฒ ํ๋ก์ฐ์ ๋ค ๋ค์ด์์๋ค๋ ๋ป ์๋๊ฐ์??ใ
- 0
- 1
- 385
Q&A
500 status
(์ฌ์ง) (์ฌ์ง)
- 0
- 2
- 342
Q&A
500 status
app.js const express = require('express'); const cors = require('cors') const db = require('./models') const app = express(); db.sequelize.sync(); app.use(cors('http://localhost:3000')) app.use(express.json()) app.use(express.urlencoded({ extended: false })) app.get('/', (req, res) => { res.status(200).send('Hello backend') }) app.post('/user', async (req, res, next) => { try { const newUser = await db.User.create({ where: { nickname: req.body.nickname, email: req.body.email, password: req.body.password, } }) res.status(201).json(newUser); } catch (err) { console.log(err) next(err) } }) app.listen(3085, () => { console.log(`๋ฐฑ์๋ ์๋ฒ ${3085}๋ฒ ํฌํธ์์ ์๋์ค`) }) user.js module.exports = (sequelize, DataTypes) => { const User = sequelize.define('User', { email: { type: DataTypes.STRING(40), allowNull: false, }, nickname: { type: DataTypes.STRING(20), allowNull: false, }, password: { type: DataTypes.STRING(100), allowNull: false, }, }, { charset: 'utf8', collate: 'utf8_general_ci' }) User.associate = (db) => { } return User } front์ signup.vue methods: { onSubmitForm() { if(this.$refs.form.validate()) { this.$store.dispatch('users/signUp', { nickname: this.nickname, email: this.email, password: this.password }) .then(() => { this.$router.push({ path: '/' }); }) .catch(() => { alert('ํ์๊ฐ์ ์คํจ') }) } } }, front์ user.js signUp({commit, state}, payload) { this.$axios.post('http://localhost:3085/user', { nickname: payload.nickname, email: payload.email, password: payload.password, }); commit('setMe', payload) },
- 0
- 2
- 342
Q&A
๊ฐ์ ๋ฃ๋์ค ์๋ฌ๊ฐ ๋ ์ ์ง๋ฌธ ๋๋ฆฝ๋๋ค ใ
index.js ์ '../config/config.json ์ด๋ถ๋ถ ์์ ์ฌ๋์ฌ ํ๋๊ฐ ๋ ๋ค์ด ๊ฐ๊ฑฐ ๊ฐ์์ ์ ๊ฑฐํ๊ณ npm run dev๋ฅผ ํด๋ณด๋ ์ด๋ฒ์ ์ข ๋ค๋ฅด๊ฒ ๋จ๋ค์ ใ ใ [nodemon] restarting due to changes... [nodemon] starting `node app.js` ๋ฐฑ์ค๋ ์๋ฒ 3085๋ฒ ํฌํธ์์ ์๋์ค (node:26792) UnhandledPromiseRejectionWarning: SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:3306 at ConnectionManager.connect (C:\Users\com\vue๊ฐ์ข\๋ผ์ฐํฐ๋ณต์ต\ch4\back\node_modules\sequelize\lib\dialects\mysql\connection-manager.js:116:17) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async ConnectionManager._connect (C:\Users\com\vue๊ฐ์ข\๋ผ์ฐํฐ๋ณต์ต\ch4\back\node_modules\sequelize\lib\dialects\abstract\connection-manager.js:318:24) at async C:\Users\com\vue๊ฐ์ข\๋ผ์ฐํฐ๋ณต์ต\ch4\back\node_modules\sequelize\lib\dialects\abstract\connection-manager.js:250:32 at async ConnectionManager.getConnection (C:\Users\com\vue๊ฐ์ข\๋ผ์ฐํฐ๋ณต์ต\ch4\back\node_modules\sequelize\lib\dialects\abstract\connection-manager.js:280:7) at async C:\Users\com\vue๊ฐ์ข\๋ผ์ฐํฐ๋ณต์ต\ch4\back\node_modules\sequelize\lib\sequelize.js:613:26 at async MySQLQueryInterface.createTable (C:\Users\com\vue๊ฐ์ข\๋ผ์ฐํฐ๋ณต์ต\ch4\back\node_modules\sequelize\lib\dialects\abstract\query-interface.js:225:12) at async Function.sync (C:\Users\com\vue๊ฐ์ข\๋ผ์ฐํฐ๋ณต์ต\ch4\back\node_modules\sequelize\lib\model.js:1300:5) at async Sequelize.sync (C:\Users\com\vue๊ฐ์ข\๋ผ์ฐํฐ๋ณต์ต\ch4\back\node_modules\sequelize\lib\sequelize.js:793:35) (Use `node --trace-warnings ...` to show where the warning was created) (node:26792) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:26792) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. ๋นจ๊ฐ๊ฒ ๋จ์ง ์๋๊ฑฐ ๋ณด๋ ์๋ฌ๊ฐ์๊ฑด ์๋๊ฑฐ ๊ฐ์๋ฐ ใ ๋ฐฑ์ค๋ ๋ค์ด์์ ํ๋๋ค์ ใ
- 0
- 5
- 1.1K
Q&A
๊ฐ์ ๋ฃ๋์ค ์๋ฌ๊ฐ ๋ ์ ์ง๋ฌธ ๋๋ฆฝ๋๋ค ใ
์ฝ๋๋ฅผ ๋ชป์ฌ๋ ค ์ฌ๋ ค๋๋ฆฝ๋๋ค!
- 0
- 5
- 1.1K
Q&A
๊ฐ์ ๋ฃ๋์ค ์๋ฌ๊ฐ ๋ ์ ์ง๋ฌธ ๋๋ฆฝ๋๋ค ใ
app.js const express = require('express'); const db = require('./models') const app = express(); db.sequelize.sync(); app.use(express.json()); app.use(express.urlencoded({ extended: false })) app.get('/', (req, res) => { res.send('์๋ ์ํ๋ผ์ด์ฆ') }) app.post('/user', async (req, res) => { try { const newUser = await db.User.create({ where: { email: req.body.email, nickname: req.body.nickname, password: req.body.password, } }) res.status(201).json() } catch (err) { console.log(err) next(err) } }) app.listen(3085, () => { console.log(`๋ฐฑ์ค๋ ์๋ฒ ${3085}๋ฒ ํฌํธ์์ ์๋์ค`) })
- 0
- 5
- 1.1K
Q&A
๊ฐ์ ๋ฃ๋์ค ์๋ฌ๊ฐ ๋ ์ ์ง๋ฌธ ๋๋ฆฝ๋๋ค ใ
user.js module.exports = (sequelize, DataTypes) => { const User = sequelize.define('User', { email: { type: DataTypes.STRING(40), // 40์ ์ด๋ด allowNull: false, // ํ์ unique: true, // ์ค๋ณต๊ธ์ง }, nickname: { type: DataTypes.STRING(20), allowNull: false, }, password: { type: DataTypes.STRING(100), allowNull: false, }, }, { charset: 'utf8', collate: 'utf8_general_ci', // ํ๊ธ ์ ์ฅ๋ผ์ }); User.associate = (db) => { db.User.hasMany(db.Post); db.User.hasMany(db.Comment); }; return User; };
- 0
- 5
- 1.1K
Q&A
๊ฐ์ ๋ฃ๋์ค ์๋ฌ๊ฐ ๋ ์ ์ง๋ฌธ ๋๋ฆฝ๋๋ค ใ
index.js const Sequelize = require('sequelize'); const env = process.env.NODE_ENV || 'development'; const config = require('/../config/config.json')[env]; const db = {}; const sequelize = new Sequelize(config.database, config.username, config.password, config); db.User = require('./user')(sequelize, Sequelize) Object.keys(db).forEach(modelName => { if (db[modelName].associate) { db[modelName].associate(db); } }); db.sequelize = sequelize; db.Sequelize = Sequelize; module.exports = db;
- 0
- 5
- 1.1K
Q&A
LoadPostsrk๊ฐ ์คํ์ด ์๋ฉ๋๋ค ใ
๊ฐ์ฌ๋๊ป์๋ ์คํฌ๋กค์ ๋ด๋ฆด๋๋ง๋ค ์๋์ผ๋ก ๋๋ฏธ๋ฐ์ดํฐ๋ ๋์ค๊ณ ๋ทฐ ๋ฐ๋ธํด์ loadPosts๋ ์ฐํ๋๋ฐ ๊ทธ๊ฒ ํซ๋ฆฌ๋ก๋ฉ๋๋ฌธ๋ฐ ์ ์๊ฐ์ ์ํฉ์ด ๋ํ๋ ์ ์๋๊ฑด๊ฐ์??
- 0
- 2
- 245




