diff --git a/pages/api/persons/urls.js b/pages/api/persons/urls.js new file mode 100644 index 00000000..da82658f --- /dev/null +++ b/pages/api/persons/urls.js @@ -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` + }) + } +}