1234567891011121314151617181920212223242526272829303132333435 |
- function HttpService(apiUrl) {
- this.getAllStudents = function() {
- return $.ajax({
- url: `${apiUrl}/students`,
- method: 'GET'
- });
- // $.get(`${api}/students`);
- };
- this.getStudentById = function(id) {
- return $.ajax({
- url: `${apiUrl}/students/${id}`,
- method: 'GET'
- });
- };
- this.updateStudentsById = function(id, data) {
- return $.ajax({
- url: `${apiUrl}/students/${id}`,
- method: 'PUT',
- data: data
- });
- };
- this.deleteStudentById = function(id) {
- return $.ajax({
- url: `${apiUrl}/students/${id}`,
- method: 'DELETE'
- });
- };
- this.postStudentsById = function(data) {
- return $.ajax({
- url: `${apiUrl}/students`,
- method: 'POST',
- data: data
- });
- };
- }
|