-
Notifications
You must be signed in to change notification settings - Fork 0
AJAX Front End
Leah Copeland edited this page Mar 5, 2021
·
20 revisions
/service/author/{AUTHOR_ID}/nonfollowers/ to retrieve a json response containing users that the logged in user may follow/send a friend request to
- Request method: GET
function fetchJSON(url) {
var request = new Request(url);
return fetch(request).then((response) => {
if (response.status === 200 || response.status == 404) {
return response.json(); // return a Promise
} else {
alert("Something went wrong: " + response.status);
}
});
}
/service/author/{AUTHOR_ID}/followers/ to retrieve a json response containing users that are following the logged in user (sending a friend request to the logged in user)
- Request method: GET
function fetchJSON(url) {
var request = new Request(url);
return fetch(request).then((response) => {
if (response.status === 200 || response.status == 404) {
return response.json(); // return a Promise
} else {
alert("Something went wrong: " + response.status);
}
});
}
/service/author/{AUTHOR_ID}/friends/ to retrieve a json response containing users that are friends with the logged in user (both users are following each other)
- Request method: GET
function fetchJSON(url) {
var request = new Request(url);
return fetch(request).then((response) => {
if (response.status === 200 || response.status == 404) {
return response.json(); // return a Promise
} else {
alert("Something went wrong: " + response.status);
}
});
}
/service/author/{AUTHOR_ID}/friends/ to retrieve a list of users that are following the logged in user (that are friend requesting them)
- Request method: GET
function fetchJSON(url) {
var request = new Request(url);
return fetch(request).then((response) => {
if (response.status === 200 || response.status == 404) {
return response.json(); // return a Promise
} else {
alert("Something went wrong: " + response.status);
}
});
}
- Request method: PUT -!important: in this instance {AUTHOR_ID} is the author the logged in user is following and {FOREIGN_AUTHOR_ID} is the current logged in users id
follow(url).done(function(response) {
console.log(response);
});
function follow(url){
return $.ajax({
url: url,
type: 'PUT',
contentType: "application/json",
success: function(result) {
console.log(result)
}
})
}
/service/author/{AUTHOR_ID}/followers/{FOREIGN_AUTHOR_ID}/ to follow a user/friend request a user back
- Request method: PUT
- !important: in this instance {AUTHOR_ID} is the author the logged in user is following and {FOREIGN_AUTHOR_ID} is the current logged in users id
AddFollowerBack(url).done(function(response) {
console.log(response);
});
function AddFollowerBack(url){
return $.ajax({
url: url,
type: 'PUT',
contentType: "application/json",
success: function(result) {
console.log(result)
}})
}
/service/author/{AUTHOR_ID}/followers/{FOREIGN_AUTHOR_ID}/ to remove a friend from a friend list (also removes friends from followers)
/service/author/{FOREIGN_AUTHOR_ID}/followers/{AUTHOR_ID}/ to remove a friend from a friend list (also removes friends from followers)
- Request method: PUT
- !important: in this instance {AUTHOR_ID} is the author the logged in user is following and {FOREIGN_AUTHOR_ID} is the current logged in users id
- !important: calls must be made to both url listed above
function remove(url){
$.ajax({
url: url,
type: 'DELETE',
contentType: "application/json",
success: function(result) {
console.log(result)
}
})
}
Citrus Network: Join the citrusy movement and take control of your own data!
Copyright (C) 2021 Alex Bali, Joe Ha, Kyle Fujishige, Leah Copeland, Nhan Nguyen