title: GET http://localhost:3000/api/jobdetail 404 (Not Found)
body: <p>In my database(MongoDB) I have 2 collections called users and jobdetail.I'm trying to connect to second collection jobdetail &amp; retrieve the data. This is my app.js code.</p>
  
  <pre><code>const express = require('express');
  const path = require('path');
  const bodyParser = require('body-parser');
  const cors = require('cors');
  const passport = require('passport');
  const mongoose = require('mongoose');
  const config = require('./config/database');
  // Connect To Database
  mongoose.connect(config.database);
  // On Connection
  mongoose.connection.on('connected', () =&gt; {
      console.log('Connected to database '+config.database);
  });
  
  // On Error
  mongoose.connection.on('error', (err) =&gt; {
      console.log('Database error: '+err);
  });
  
  const app = express();
  const port = 3000;
  
  const users = require('./routes/users');
  
  
  
  // Set Static Folder
  app.use(express.static(path.join(__dirname, 'public')));
  
  app.get('/', (req, res) =&gt; { 
      res.send('Invalid endpoint');
  });
  
  // Body Parser Middleware
  app.use(bodyParser.json());
  
  app.use(function(req, res, next) {
      res.header("Access-Control-Allow-Origin", "*");
      res.header("Access-Control-Allow-Methods", "GET,HEAD,OPTIONS,POST,PUT");
      res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization");
      next();
    });
  
  // Passport Middleware
  app.use(passport.initialize());
  app.use(passport.session());
  
  require('./config/passport')(passport);
  app.use('/users', users);
  
  // CORS Middleware
  app.use(cors());
  app.listen(port, () =&gt; {
     console.log("Server started on port:", port); 
  });
  </code></pre>
  
  <p>This is my routes file</p>
  
  <pre><code>const express = require('express');
  const router = express.Router();
  const passport = require('passport');
  const config = require('../config/database');
  const jwt = require('jsonwebtoken');
  const User = require('../models/user');
  
  // Register
  router.post('/register', (req, res, next) =&gt; {
      //code
        });
  
        User.addUser(newUser, (err, user) =&gt; {
          if(err){
            res.json({success: false, msg:'Failed to register user'});
          } else {
            res.json({success: true, msg:'User registered'});
          }
        });
  });
  
  // Update User
  router.post('/update', function(req, res, next) {
    //code
  
  })
  
  
  // Authenticate
  router.post('/authenticate', (req, res, next) =&gt; {
      const username = req.body.username;
    const password = req.body.password;
  
    User.getUserByUsername(username, (err, user) =&gt; {
      if(err) throw err;
      if(!user){
        return res.json({success: false, msg: 'User not found'});
      }
  
      User.comparePassword(password, user.password, (err, isMatch) =&gt; {
        if(err) throw err;
        if(isMatch){
          const token = jwt.sign(user, config.secret, {
            expiresIn: 604800 // 1 week
          });
  
          res.json({
            success: true,
            token: 'JWT '+token,
            user: {
              id: user._id,
              name: user.name,
              username: user.username,
              email: user.email
            }
          });
        } else {
          return res.json({success: false, msg: 'Wrong password'});
        }
      });
    });
  });
  
  //get job details 
  router.get('/jobdetail', function(req,res) {
    console.log('fetching jobs');
    jobDetails.find(function(err,jobs) {
      if(err) {
        console.log(err);
      }
      else {
        res.json(jobs);
      }
    });
  });
  
  
  
  
  
  
  // Profile
  router.get('/profile', passport.authenticate('jwt', {session:false}), (req, res, next) =&gt; {
      res.json({user: req.user});
    });
  
  
  
  module.exports = router;
  </code></pre>
  
  <p>This is provider.ts file </p>
  
  <pre><code>getJobDetails() {
      if(this.data) {
        return Promise.resolve(this.data);
      }
      return new Promise(resolve =&gt;{
        this.http.get('http://localhost:3000/api/jobdetail')
        .map(res =&gt; res.json())
        .subscribe(data =&gt; {
          this.data = data;
          resolve(this.data);
        });
      });
    }
  </code></pre>
  
  <p>I'm getting the error like </p>
  
  <blockquote>
    <p>polyfills.js:3 GET <a href="http://localhost:3000/api/jobdetail" rel="nofollow noreferrer">http://localhost:3000/api/jobdetail</a> 404 (Not Found)
    s @ polyfills.js:3 t.scheduleTask @ polyfills.js:3 onScheduleTask @
    polyfills.js:3 t.scheduleTask @ polyfills.js:3 r.scheduleTask @
    polyfills.js:3 r.scheduleMacroTask @ polyfills.js:3 (anonymous) @
    polyfills.js:3 o.(anonymous function) @ polyfills.js:2 (anonymous) @
    http.js:1640 Observable._trySubscribe @ Observable.js:172
    Observable.subscribe @ Observable.js:160 MapOperator.call @ map.js:56
    Observable.subscribe @ Observable.js:157 (anonymous) @ jobs-data.ts:23
    t @ polyfills.js:3 webpackJsonp.181.JobsDataProvider.getJobDetails @
    jobs-data.ts:20 webpackJsonp.260.FeedsPage.ionViewDidLoad @
    feeds.ts:63 ViewController._lifecycle @ view-controller.js:486
    ViewController._didLoad @ view-controller.js:369
    NavControllerBase._didLoad @ nav-controller-base.js:768 t.invoke @
    polyfills.js:3 onInvoke @ core.js:4749 t.invoke @ polyfills.js:3 r.run
    @ polyfills.js:3 NgZone.run @ core.js:4566
    NavControllerBase._viewAttachToDOM @ nav-controller-base.js:463
    NavControllerBase._transition @ nav-controller-base.js:540 (anonymous)
    @ nav-controller-base.js:261 t.invoke @ polyfills.js:3 onInvoke @
    core.js:4749 t.invoke @ polyfills.js:3 r.run @ polyfills.js:3
    (anonymous) @ polyfills.js:3 t.invokeTask @ polyfills.js:3
    onInvokeTask @ core.js:4740 t.invokeTask @ polyfills.js:3 r.runTask @
    polyfills.js:3 o @ polyfills.js:3 Promise.then (async) r @
    polyfills.js:3 t.scheduleTask @ polyfills.js:3 onScheduleTask @
    polyfills.js:3 t.scheduleTask @ polyfills.js:3 r.scheduleTask @
    polyfills.js:3 r.scheduleMicroTask @ polyfills.js:3 f @ polyfills.js:3
    c @ polyfills.js:3 (anonymous) @ polyfills.js:3 webpackJsonpCallback @
    bootstrap ac2fad340272940ddf57:21 (anonymous) @ 0.js:1 core.js:1448
    ERROR Response {_body: "↵↵↵Cannot GET /api/jobdetail↵↵↵", status: 404,
    ok: false, statusText: "Not Found", headers: Headers, …}headers:
    Headers {_headers: Map(1), _normalizedNames: Map(1)}ok: falsestatus:
    404statusText: "Not Found"type: 2url:
    "<a href="http://localhost:3000/api/jobdetail" rel="nofollow noreferrer">http://localhost:3000/api/jobdetail</a>"_body: "↵↵↵↵Error↵↵↵<pre>Cannot GET
  /api/jobdetail</pre>↵↵↵"<strong>proto</strong>: Body
    defaultErrorLogger @ core.js:1448 ErrorHandler.handleError @
    core.js:1509 IonicErrorHandler.handleError @ ionic-error-handler.js:61
    next @ core.js:5497 schedulerFn @ core.js:4331
    SafeSubscriber.__tryOrUnsub @ Subscriber.js:239 SafeSubscriber.next @
    Subscriber.js:186 Subscriber._next @ Subscriber.js:126 Subscriber.next
    @ Subscriber.js:90 Subject.next @ Subject.js:55 EventEmitter.emit @
    core.js:4311 (anonymous) @ core.js:4771 t.invoke @ polyfills.js:3
    r.run @ polyfills.js:3 NgZone.runOutsideAngular @ core.js:4697
    onHandleError @ core.js:4771 t.handleError @ polyfills.js:3 r.runTask
    @ polyfills.js:3 e.invokeTask @ polyfills.js:3 p @ polyfills.js:2 v @
    polyfills.js:2 error (async) O @ polyfills.js:2 t.scheduleTask @
    polyfills.js:3 onScheduleTask @ polyfills.js:3 t.scheduleTask @
    polyfills.js:3 r.scheduleTask @ polyfills.js:3 r.scheduleEventTask @
    polyfills.js:3 (anonymous) @ polyfills.js:2 (anonymous) @ http.js:1639
    Observable._trySubscribe @ Observable.js:172 Observable.subscribe @
    Observable.js:160 MapOperator.call @ map.js:56 Observable.subscribe @
    Observable.js:157 (anonymous) @ jobs-data.ts:23 t @ polyfills.js:3
    webpackJsonp.181.JobsDataProvider.getJobDetails @ jobs-data.ts:20
    webpackJsonp.260.FeedsPage.ionViewDidLoad @ feeds.ts:63
    ViewController._lifecycle @ view-controller.js:486
    ViewController._didLoad @ view-controller.js:369
    NavControllerBase._didLoad @ nav-controller-base.js:768 t.invoke @
    polyfills.js:3 onInvoke @ core.js:4749 t.invoke @ polyfills.js:3 r.run
    @ polyfills.js:3 NgZone.run @ core.js:4566
    NavControllerBase._viewAttachToDOM @ nav-controller-base.js:463
    NavControllerBase._transition @ nav-controller-base.js:540 (anonymous)
    @ nav-controller-base.js:261 t.invoke @ polyfills.js:3 onInvoke @
    core.js:4749 t.invoke @ polyfills.js:3 r.run @ polyfills.js:3
    (anonymous) @ polyfills.js:3 t.invokeTask @ polyfills.js:3
    onInvokeTask @ core.js:4740 t.invokeTask @ polyfills.js:3 r.runTask @
    polyfills.js:3 o @ polyfills.js:3 Promise.then (async) r @
    polyfills.js:3 t.scheduleTask @ polyfills.js:3 onScheduleTask @
    polyfills.js:3 t.scheduleTask @ polyfills.js:3 r.scheduleTask @
    polyfills.js:3 r.scheduleMicroTask @ polyfills.js:3 f @ polyfills.js:3
    c @ polyfills.js:3 (anonymous) @ polyfills.js:3 webpackJsonpCallback @
    bootstrap ac2fad340272940ddf57:21 (anonymous) @ 0.js:1</p>
  </blockquote>
  
  <p>I've also tried it using postman it displaying the error as </p>
  
  <blockquote>
    <p> 
        
            
            Error
            
        
        
          <pre>Cannot GET /api/jobdetail</pre>
         </p>
  </blockquote>