leonsuke

StudentController

Apr 3rd, 2019
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. 'use strict'
  2.  
  3. const got = use ('got')
  4. const edge = use('edge.js')
  5.  
  6. /** @typedef {import('@adonisjs/framework/src/Request')} Request */
  7. /** @typedef {import('@adonisjs/framework/src/Response')} Response */
  8. /** @typedef {import('@adonisjs/framework/src/View')} View */
  9.  
  10. /**
  11. * Resourceful controller for interacting with students
  12. */
  13. class StudentController {
  14. /**
  15. * Show a list of all students.
  16. * GET students
  17. *
  18. * @param {object} ctx
  19. * @param {Request} ctx.request
  20. * @param {Response} ctx.response
  21. * @param {View} ctx.view
  22. */
  23. async index ({ request, response, view }) {
  24. const student_api_val = await got('http://127.0.0.1:3333/api/student/show/1')
  25.  
  26. return view.render('student.index', { adonisuser: student_api_val.body.toJSON()})
  27. // console.log(student_api_val.body)
  28. }
  29.  
  30. /**
  31. * Render a form to be used for creating a new student.
  32. * GET students/create
  33. *
  34. * @param {object} ctx
  35. * @param {Request} ctx.request
  36. * @param {Response} ctx.response
  37. * @param {View} ctx.view
  38. */
  39. async create ({ request, response, view }) {
  40. }
  41.  
  42. /**
  43. * Create/save a new student.
  44. * POST students
  45. *
  46. * @param {object} ctx
  47. * @param {Request} ctx.request
  48. * @param {Response} ctx.response
  49. */
  50. async store ({ request, response }) {
  51. }
  52.  
  53. /**
  54. * Display a single student.
  55. * GET students/:id
  56. *
  57. * @param {object} ctx
  58. * @param {Request} ctx.request
  59. * @param {Response} ctx.response
  60. * @param {View} ctx.view
  61. */
  62. async show ({ params, request, response, view }) {
  63. }
  64.  
  65. /**
  66. * Render a form to update an existing student.
  67. * GET students/:id/edit
  68. *
  69. * @param {object} ctx
  70. * @param {Request} ctx.request
  71. * @param {Response} ctx.response
  72. * @param {View} ctx.view
  73. */
  74. async edit ({ params, request, response, view }) {
  75. }
  76.  
  77. /**
  78. * Update student details.
  79. * PUT or PATCH students/:id
  80. *
  81. * @param {object} ctx
  82. * @param {Request} ctx.request
  83. * @param {Response} ctx.response
  84. */
  85. async update ({ params, request, response }) {
  86. }
  87.  
  88. /**
  89. * Delete a student with id.
  90. * DELETE students/:id
  91. *
  92. * @param {object} ctx
  93. * @param {Request} ctx.request
  94. * @param {Response} ctx.response
  95. */
  96. async destroy ({ params, request, response }) {
  97. }
  98. }
  99.  
  100. module.exports = StudentController
Advertisement
Add Comment
Please, Sign In to add comment