F
F
FeDroid742022-04-15 11:46:01
JavaScript
FeDroid74, 2022-04-15 11:46:01

When sending a GET request to Postman, the server endlessly processes this request, what is the error?

With a POST request, everything is fine and it works correctly, which can be seen from the database, but GET requests for both category and brand are processed indefinitely and the server does not give any error, what could be the reason?
625930a7a1f24909271514.png

brandController code

const {Brand} = require('../models/models')
const ApiError = require('../error/ApiError')

class BrandController {
    async create(req, res) {
        const {name} = req.body
        const brand = await Brand.create({name})
        return res.json(brand)
    }

    async getOne(req, res) {

    }

    async getAll(req, res, next) {
            try {
                const brands = await Brand.findAll()
                res.json(brands)
            } catch(e) {
                next(ApiError.badRequest(e.message))
            }
    }

    async update(req, res) {

    }

    async delete(req, res) {

    }
}

module.exports = new BrandController()


brandRouter code
const Router = require('express')
const router = new Router()
const brandController = require('../controllers/brandController')


router.post('/', brandController.create)
router.get('/', brandController.getOne)
router.get('/', brandController.getAll)
router.put('/', brandController.update)
router.delete('/', brandController.delete)

module.exports = router


I haven't added features to other requests yet because I want to get to grips with these.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question