Express.js Tutorial: Building RESTful APIs with Node and Express




Express.js Tutorial: Building RESTful APIs with Node Express Get the COMPLETE Course (70% OFF – LIMITED TIME): http://bit.ly/2NduewZ Subscribe for more …

Original source


47 responses to “Express.js Tutorial: Building RESTful APIs with Node and Express”

  1. Hey, great tutorial but one question. When trying to do the put function, even when I use "name": "new course" I always get the message "name" is required. (copied your code exactly I think) Any ideas why this might be happening?

  2. Hi Mosh, thanks a lot for sharing this tutorial with us.

    I have a question regarding the line:

    const course = courses.find(c => c.id === parseInt(req.params.id));

    where you have used 'c' at time 28:41 in your video.
    Could you please explain me how this work. Or may be provide me the name of the convention so that I can research myself.

    Thank you!!

  3. Great tutorial. I always like it when an instructor can admit that there was a bug in what they were coding. Very humble and I like seeing the trouble shooting that the teacher goes through. Great course, I am studying writing smart contracts for cryptocurrencies, and originally watched your video because it came up in a list of videos under the query 'json'. Very fortunate that I found your work, I will be back to udemy to take your course!

  4. Bought the course which is ok but everyone should know that after you buy the course you get 'ZERO' support from Mr. Mosh or the team … you are completely on your own … they DO NOT offer any help or support what so ever … I've bought other courses from other sources also and they're not only cheaper but also they provide a lot of help afterward, but not here … so be careful all !! This is what I get repeatedly from Mosh's team: "Hi,

    Due to the large volume of requests, we can not offer technical support or answers to individual questions at this time. If you have more generic questions, it may be best to post them on stackoverflow.com.

    Thank you so much!" … and they don't have any support forum either, trust me I've asked …

  5. I was struggling learning how to create a server with node and express. This tutorial is really easy to understand and well-structured for beginners. This is so far the best tutorial on Youtube!!! Thank you so much, Mosh!!!

  6. hi Mosh. I realy love your courses, very beatiful explanations of hard things. But appeared a problem by my side. Could it's possible to give a hand?
    I stopped on Input validation, I did all that I needed. The versions of Joi, express..and the code is absolutely similar. I installed postman, but it validate all requests even integers; I tryied many variants, but it likes filters of Joi doesn't work on my PC. I'll try on ubuntu 16.04. Below is the code:

    const Joi = require('joi');
    const express = require ('express');
    const app = express();
    app.use(express.json());

    const courses=[
    { id:1, name:'course1'},
    { id:2, name:'course2'},
    { id:3, name:'course3'},
    ];

    app.get('/', (req, res)=>{
    res.send('ok');
    });
    app.get('/api/courses', (req, res)=>{
    res.send(course);
    });

    app.post('api/courses', (req, res) => {
    const schema={
    name: Joi.string().min(3).required()
    };
    const result = Joi.validate(req.body, schema);

    if(result.error){
    res.status(400).send(result.error.details[0].message);
    return;
    }
    });

    app.post('/api/courses', (req, res)=>{
    const course ={
    id:courses.length+1,
    name: req.body.name
    };
    courses.push(course);
    res.send(course);
    });

    app.get('/api/courses/:id', (req, res)=>{
    const course = courses.find(c=>c.id===parseInt(req.params.id));
    if(!course) res.status(404).send('The course with given ID is not found');
    res.send(course);
    });

    const port = process.env.PORT || 3000;
    app.listen(port, ()=> console.log(`listening on ${port}…`));

  7. Knew most of this, but I still watched the entire tutorial because it was so incredibly well structured and didactic.
    You are a born teacher. I've often fantasized about making great and clear youtube tutorials, in my wildest most perfect fantasies, they looked exactly like the stuff you actually make! Incredible!

  8. How do you know what will be returned from the request " require("module_name") " .

    For example you said require("express") returns a function and require("joi") returns a class. I am wondering where i can find those information.

  9. one more potential check: the course id passed may not be a parseable int. one needs to test / return error message. so a suggested order for input validation might be (i) is the id parseable, (ii) is the message valid, and then (iii) does the id exist. looking up the id (step iii) is the most expensive one and should only be performed after all pre-requisites are satisfied.

  10. at 28:00, in courses.find() i would move parseInt(req.parameters.id) to the outside of the find(), so parseIntI() is not called for every element, i.e.:

    const id = parseInt(req.params.id);
    const course = courses.find(c => c.id === id);

    thoughts?

  11. I find your curricula competencies and content spreading strategies accurate and efficient. It looks like a dominos effect learning. I never coded with Express.js. and I really got all the logic behind it easily .
    Thanks for this great course.

Leave a Reply