SHARE

Hey gang, in this REST API tutorial I’ll show you how we can make some simple middleware to handle our validation errors.

—– COURSE LINKS:
+ Repo – https://github.com/iamshaunjp/rest-api-playlist
+ Atom editor – https://atom.io/a
+ Download GIT – https://git-scm.com/
+ Node.js for Beginners Playlist –
https://www.youtube.com/playlist?list=PL4cUxeGkcC9gcy9lrvMJ75z9maRw4byYp
+ MongoDB playlist – https://www.youtube.com/playlist?list=PL4cUxeGkcC9jpvoYriLI0bY8DOgWZfi6u

———————————————————————————————
You can find more front-end development tutorials on CSS, HTML, JavaScript, jQuery, WordPress, Node.js & more on the channel homepage…

SUBSCRIBE TO CHANNEL – https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg?sub_confirmation=1

========== PSD to WordPress Playlist ==========

https://www.youtube.com/playlist?list=PL4cUxeGkcC9gnow7e45LQFkNVxwQ5BH-W

============ Node.js for Beginners Playlist =============

https://www.youtube.com/playlist?list=PL4cUxeGkcC9gcy9lrvMJ75z9maRw4byYp

============== The Net Ninja =====================

For more front-end development tutorials & to black-belt your coding skills, head over to – https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg or http://thenetninja.co.uk

================== Social Links ==================

Twitter – @TheNetNinja – https://twitter.com/thenetninjauk

9 COMMENTS

  1. I'm unable to trigger an error. I'm sending an 'api/post' request without a body to trigger an error, but no error is occurring. The request is going through, even though I have required fields for my schema. Why does this happen?

  2. Hi Ninja! when the document is save in mongo database, the properties "name" and "rank" are not save, just "available" is storaged! Do you know why is happen?

  3. Hey, Im working on a project of my own and I want that the API to interact with both a web app and an Ionic App. The ionic app would be receiving data and store it so that It could be checked by an admin on the web app side. Would you have any recommendations and would this tutorial serve the data in the same way to the Ionic app?

  4. Tnx, great solution!
    I Try implement error handler like this(without "next" in params), but in result app is falling down.
    app.use(function (err, req, res) {
    res.status(422).json({ error: err});
    });
    I understand, "next" pass request to next middleware, but this error handler is last in chain.
    So could you explain please what doing "next" in this case ? Thank you!

LEAVE A REPLY

Please enter your comment!
Please enter your name here