-4

I'm using vs code to develop my project using node.js. The problem is that API is not working when I run in postman and insomania the following error is given below:

Error 404

::ffff:127.0.0.1 - - [19/Oct/2022:04:07:36 +0000] "GET /api/prayer/create HTTP/1.1" 404 57 "-" "insomnia/2022.6.0"

Router code

const { Router } = require('express');
const prayerControllor = require('../controllers/prayer.controller');

const { celebrate, Joi } = require('celebrate');

module.exports = function (app) {

    const route = Router();
    app.use('/prayer', route);

    route.post('/create', celebrate({
        body: {
            prayerName: Joi.string().required(),
            iqamatTime: Joi.string().required(),
            namasTime: Joi.string().required(),

        }
    }), prayerControllor.createPrayer);
    route.patch('/update/:id', prayerControllor.updatePrayer);
    route.get('/get/:id', prayerControllor.getPrayer);
}
Anveeg Sinha
  • 415
  • 1
  • 4
  • 15

1 Answers1

0

Ideally, I would need to look at more code to understand hour your routes are configured as from where '/api' path is coming.

Most likely issue is that you are trying GET call whereas your route is configured as POST.

Karan Singla
  • 373
  • 1
  • 4
  • 9