Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. import students from '../dummy/students.js';
  2. class StudentController {
  3. // Get all students
  4. static getAllStudents(req, res) {
  5. return res.status(200).json({
  6. students,
  7. message: "All the students",
  8. });
  9. }
  10. // Get a single student
  11. static getSingleStudent(req, res) {
  12. const findStudent = students.find(student => student.id === parseInt(req.params.id, 10));
  13. if (findStudent) {
  14. return res.status(200).json({
  15. student: findStudent,
  16. message: "A single student record",
  17. });
  18. }
  19. return res.status(404).json({
  20. message: "Student record not found",
  21. });
  22. }
  23. }
  24. export default StudentController;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement