xExekut3x

category.js

Dec 5th, 2015
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. var category = (function () {
  2.  
  3. return {
  4.  
  5. load: function () {
  6.  
  7. var opts = {
  8. method: 'GET',
  9. url: '/api/category',
  10. headers: {'Content-Type': 'application/json;charset=UTF-8'}
  11. };
  12.  
  13. http.makeRequest(opts)
  14. .then(function (response) {
  15. console.log(response); // returns what's in the database
  16. return JSON.parse(response);
  17. })
  18. .catch(function (response) {
  19. console.error(response);
  20. });
  21.  
  22. },
  23.  
  24. create: function (name) {
  25.  
  26. var opts = {
  27. method: 'POST',
  28. url: '/api/category',
  29. params: {
  30. name: name
  31. },
  32. headers: {'Content-Type': 'application/x-www-form-urlencoded'}
  33. };
  34.  
  35. http.makeRequest(opts)
  36. .then(function (response) {
  37. console.log(response);
  38. })
  39. .catch(function (response) {
  40. console.error(response);
  41. });
  42.  
  43. },
  44.  
  45. edit: function (id, name) {
  46.  
  47. },
  48.  
  49. delete: function (id) {
  50.  
  51. }
  52. };
  53.  
  54. }());
Advertisement
Add Comment
Please, Sign In to add comment