service.js 674 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. function HttpService(server) {
  2. this.getStudents = function() {
  3. return $.ajax({
  4. url: server + '/students'
  5. });
  6. }
  7. this.getStudentsById = function(studentId) {
  8. return $.ajax({
  9. url: server + '/students/' + studentId,
  10. method: 'GET'
  11. });
  12. }
  13. this.updateUserById = function(studentId, data) {
  14. return $.ajax({
  15. url: server + '/students/' + studentId,
  16. method: 'PUT',
  17. data: data
  18. });
  19. }
  20. this.createStudent = function(data) {
  21. return $.ajax({
  22. url: server + '/students',
  23. method: 'POST',
  24. data: data
  25. });
  26. }
  27. this.deleteStudent = function(studentId) {
  28. return $.ajax({
  29. url: server + '/students/' + studentId,
  30. method: 'DELETE'
  31. })
  32. }
  33. }