Answer the question
In order to leave comments, you need to log in
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?
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()
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
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question