Skip to content Skip to sidebar Skip to footer

Node Express App.js Giving A 404 Error For Get Request

I have looked at similar questions and they don't seem to answer my problem. I am getting a 404 error when I send a GET request. I have my router in a separate file and then callin

Solution 1:

You are giving twice the /movies route, so your server will respond to http://host:port/movies/movies

The movie-server.js should contain:

const express = require('express')
const movieRouter = express.Router();

movieRouter
    .route('/') // Do not repeat /movies here
    .get((req, res) => {
        res.send('hello from movies')
    })
module.exports = movieRouter;

Post a Comment for "Node Express App.js Giving A 404 Error For Get Request"