Skip to content

Instantly share code, notes, and snippets.

@cklanac
Created June 20, 2018 15:13
Show Gist options
  • Save cklanac/a64020a7e10fc4a459750f23fe2f2047 to your computer and use it in GitHub Desktop.
Save cklanac/a64020a7e10fc4a459750f23fe2f2047 to your computer and use it in GitHub Desktop.
single jquery REST calls
// Create an Item
// var settings = {
// 'url': 'https://thinkful-list-api.herokuapp.com/chris/items',
// 'method': 'POST',
// 'data': JSON.stringify({ name: 'Milk' }),
// 'success': function (res) {
// console.log(res);
// },
// 'error': function (err) {
// console.log(err);
// },
// 'headers': {
// 'Content-Type': 'application/json'
// }
// };
// Get a list of items
var settings = {
'url': 'https://thinkful-list-api.herokuapp.com/chris/items/',
'method': 'GET',
'success': function (res) {
console.log(res);
},
'error': function (err) {
console.log(err);
}
};
// Get a single item
// var settings = {
// 'url': 'https://thinkful-list-api.herokuapp.com/chris/items/cjin92qf3000g0k2vjn0yj19u',
// 'method': 'GET',
// 'success': function (res) {
// console.log(res);
// },
// 'error': function (err) {
// console.log(err);
// }
// };
// Update an item
// var settings = {
// 'url': 'https://thinkful-list-api.herokuapp.com/chris/items/cjin92qf3000g0k2vjn0yj19u',
// 'method': 'PATCH',
// 'data': JSON.stringify({ name: 'Orange Juice' }),
// 'success': function (res) {
// console.log(res);
// },
// 'error': function (err) {
// console.log(err);
// },
// 'headers': {
// 'Content-Type': 'application/json'
// }
// };
// Delete an item
// var settings = {
// 'url': 'https://thinkful-list-api.herokuapp.com/chris/items/cjin92qf3000g0k2vjn0yj19u',
// 'method': 'DELETE',
// 'success': function (res) {
// console.log(res);
// },
// 'error': function (err) {
// console.log(err);
// }
// };
$.ajax(settings);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment