diff options
Diffstat (limited to 'pages')
-rw-r--r-- | pages/api/note/[id].js | 5 | ||||
-rw-r--r-- | pages/api/notes.js | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/pages/api/note/[id].js b/pages/api/note/[id].js index 8ba3b70..46278c8 100644 --- a/pages/api/note/[id].js +++ b/pages/api/note/[id].js @@ -3,7 +3,7 @@ import withSession from 'lib/withSession' import Note from 'models/Note' export default withSession(async (req, res) => { - const { id } = req.query + const {id} = req.query await dbConnect() switch (req.method) { @@ -15,7 +15,7 @@ export default withSession(async (req, res) => { throw new Error('Something went wrong') } - const note = await Note.findById(id) + const note = await Note.getNote(id) if (!note) { throw new Error('Something went wrong') @@ -23,6 +23,7 @@ export default withSession(async (req, res) => { res.status(200).json(note) } catch (error) { + console.log(error) res.status(400).json({error: true}) } break diff --git a/pages/api/notes.js b/pages/api/notes.js index 73a7217..dd31c6f 100644 --- a/pages/api/notes.js +++ b/pages/api/notes.js @@ -78,7 +78,7 @@ export default withSession(async (req, res) => { throw new Error('Something went wrong') } - await Note.findByIdAndUpdate(noteId, {content}, {new: true}) + await Note.updateNote(noteId, content) const notes = await NoteList.findOneAndUpdate( { _id: user.noteList, "notes.noteId": noteId }, |