Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var category = (function () {
- return {
- load: function () {
- var opts = {
- method: 'GET',
- url: '/api/category',
- headers: {'Content-Type': 'application/json;charset=UTF-8'}
- };
- http.makeRequest(opts)
- .then(function (response) {
- console.log(response); // returns what's in the database
- return JSON.parse(response);
- })
- .catch(function (response) {
- console.error(response);
- });
- },
- create: function (name) {
- var opts = {
- method: 'POST',
- url: '/api/category',
- params: {
- name: name
- },
- headers: {'Content-Type': 'application/x-www-form-urlencoded'}
- };
- http.makeRequest(opts)
- .then(function (response) {
- console.log(response);
- })
- .catch(function (response) {
- console.error(response);
- });
- },
- edit: function (id, name) {
- },
- delete: function (id) {
- }
- };
- }());
Advertisement
Add Comment
Please, Sign In to add comment