Answer the question
In order to leave comments, you need to log in
Why doesn't it add mongodb to the database?
Hello everyone, I'm using the mongoose library!
I use the documentation, but after entering the data from the form, I have a load and last forever, and the data is not added to the database!
Here is the routing code (using express js)
var express = require('express')
var body_parser = require('body-parser')
var path = require('path')
const nodemailer = require('nodemailer')
const mongoose = require('mongoose')
var Schema = mongoose.Schema
var blogSchema = new Schema({
login: String,
email: String,
password: String
});
var Reg = mongoose.model('Blog', blogSchema);
var app = express()
//дальше идет подключение к бд
//Ну и сам роутинг
app.get('/auth', (req, res) => {
res.render('auth', {title: "Авторизация"})
})
app.post('/auth', (req, res) => {
console.log(req.body)
})
app.get('/register', async (req, res) => {
const register = await Reg.find({})
res.render('register', {
title: "Регистрация",
register
})
})
app.post('/register', async (req, res) => {
const register = new Reg({
login: req.body.login,
email: req.body.email,
password: req.body.password
})
await register.save()
})
app.listen(3012, () => {
console.log('Server is started')
})
Answer the question
In order to leave comments, you need to log in
I'm loading and taking forever
does not add data to database
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question