})
app.get( '/archive/note/:id', checkAjax, loadUser, function( req, res ) {
+ console.log( "id="+req.params.id)
ArchivedNote.findById(req.params.id, function(err, note) {
- if ( err ) {
- sendJson(res, {status: 'error', message: 'This is not a valid id for a note', err:err } );
+ if ( err || !note ) {
+ sendJson(res, {status: 'error', message: 'This is not a valid id for a note'} );
} else {
ArchivedCourse.findOne({id: note.course_id}, function(err, course) {
- if ( err ) {
+ if ( err || !course ) {
sendJson(res, {status: 'error', message: 'There is no course for this note'} )
} else {
sendJson(res, { 'layout' : 'notesLayout', 'note' : note, 'course': course, 'user': req.user.sanitized } );