api pages
This commit is contained in:
1 parent
606164bb43
commit
b90b2a3e77
1 file changed
+19
@@ -0,0 +1,19 @@
|
||||
import { connect } from '../../../src/core/db'
|
||||
import Page from '../../../src/core/Page'
|
||||
|
||||
export default async (req, res) => {
|
||||
await connect()
|
||||
|
||||
const items = await Page.find({})
|
||||
|
||||
if (items) {
|
||||
res.json({
|
||||
items,
|
||||
})
|
||||
} else {
|
||||
res.status(404)
|
||||
res.json({
|
||||
error: `Article ${id} not found`
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user