私は新しいルート "Dashboard"を設定しようとしていましたが、何らかの理由でwebsiteName /ダッシュボードにアクセスしようとするたびにSchemaの作業を開始しました"[]"の空白のページ。私は何が起こっているのか分かりません。ここで"[]" node.jsの空白ページ
は私のルートです:コントローラのフォルダ内
const dashboardController = require('./controllers/dashboard');
app.get('/dashboard', passportConfig.isAuthenticated, dashboardController.getDashboard);
app.post('/dashboard', passportConfig.isAuthenticated, dashboardController.postCreateTodo);
dashboard.js:モデルフォルダ内
const async = require('async');
const crypto = require('crypto');
const nodemailer = require('nodemailer');
const passport = require('passport');
const User = require('../models/User');
const Todo = require('../models/Dashboard');
/**
* GET /dashboard
*
*/
exports.getDashboard = function(req, res){
Todo.find({userId: req.user.id}, function (err, todos) {
if (err) return console.error(err);
res.send(todos);
});
};
/**
* POST /dashboard
*
*/
exports.postCreateTodo = (req, res, next) => {
User.create(req.body.todo, function(err, newTodo){
if(err){
res.render("new");
} else {
//then, redirect to the index
res.redirect("/dashboard");
}
});
};
Dashboard.js:
const bcrypt = require('bcrypt-nodejs');
const crypto = require('crypto');
const mongoose = require('mongoose');
const User = require('../models/User');
const todoSchema = new mongoose.Schema({
name: {type: String, default : ''},
User: {type: mongoose.Schema.ObjectId, ref: 'User'},
createdAt : {type : Date, default : Date.now}
});
const Todo = mongoose.model('Todo', todoSchema);
module.exports = Todo;
そして最後にdashboard.jade:
extends ../layout
block additionalCSS
link(rel='stylesheet', type='text/css', href='assets/css/todos.css')
link(href='https://fonts.googleapis.com/css?family=Roboto:400,700,500', rel='stylesheet', type='text/css')
link(rel='stylesheet', type='text/css', href=' https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.css')
link(rel='stylesheet', href='//cdnjs.cloudflare.com/ajax/libs/lemonade/2.1.0/lemonade.min.css')
script(type='text/javascript', src='assets/plugins/jquery-3.0.0.min.js')
block content
#container
.page-header
h3 Dashboard
.frame
.bit-2
h1
| Do
i.fa.fa-plus
input(type='text', placeholder='Add New Todo')
ul
li
span
i.fa.fa-trash
| Finish Daily Report
li
span
i.fa.fa-trash
| House on Fire
li
span
i.fa.fa-trash
| Crying Baby
.bit-2
h1
| Decide
i.fa.fa-plus
input(type='text', placeholder='Add New Todo')
ul
li
span
i.fa.fa-trash
| Exercising
li
span
i.fa.fa-trash
| Calling Family And Friends
li
span
i.fa.fa-trash
| Long-term Biz Strategy
|
.frame
.bit-2
h1
| Delegate
i.fa.fa-plus
input(type='text', placeholder='Add New Todo')
ul
li
span
i.fa.fa-trash
| Scheduling Interviews
li
span
i.fa.fa-trash
| Booking Flights
li
span
i.fa.fa-trash
| Answering Certain emails
.bit-2
h1
| Delete
i.fa.fa-plus
input(type='text', placeholder='Add New Todo')
ul
li
span
i.fa.fa-trash
| Watching Television
li
span
i.fa.fa-trash
| Checking Social Media
li
span
i.fa.fa-trash
| Surfing The Web
block additionalJS
script(type='text/javascript', src='assets/js/todos.js')
注:私はCRUDのためのスキーマからdashboard.jadeする形式と値で追加が完了していないすべてのヘルプは大歓迎です
を要求し、これを読むためにあなたの時間を割いていただきありがとうございます。
ありがとうございました!それは3日間私を悩ませていた。私はまだnoobです:) –