This repository has been archived on 2024-10-29. You can view files and clone it, but cannot push or open issues or pull requests.
FunctionProject/api/controllers/categories.js

15 lines
410 B
JavaScript
Raw Normal View History

2020-08-03 12:04:07 +02:00
const errorHandling = require('../assets/utils/errorHandling')
const Categories = require('../models/categories')
const { serverError } = require('../assets/config/errors')
exports.getCategories = (_req, res, next) => {
2020-08-03 12:04:07 +02:00
Categories.findAll()
2020-08-03 14:14:45 +02:00
.then(result => {
2020-08-03 12:04:07 +02:00
res.status(200).json(result)
})
2020-08-03 14:14:45 +02:00
.catch(error => {
2020-08-03 12:04:07 +02:00
console.log(error)
return errorHandling(next, serverError)
})
}