api persons urls

This commit is contained in:
tmshv committed 2019-08-01 17:39:53 +03:00
1 parent 1be8911070
commit 606164bb43
1 file changed
+20
+20
View File
@@ -0,0 +1,20 @@
import { connect } from '../../../src/core/db'
import Teacher from '../../../src/core/Teacher'
export default async (req, res) => {
await connect()
const data = await Teacher.find({})
if (data) {
const items = data.map(x => `/teacher/${x.id}`)
res.json({
items
})
} else {
res.status(404)
res.json({
error: `Not found`
})
}
}