Files
hudozka/pages/api/persons/urls.js
T
2019-08-01 17:39:53 +03:00

21 lines
421 B
JavaScript

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`
})
}
}