working on accepting friend requests, have to muck about with the DB, i have to learn how to use .find()
This commit is contained in:
@@ -41,7 +41,6 @@
|
||||
|
||||
});
|
||||
|
||||
|
||||
const fetchAllUsers = async() => {
|
||||
allUsers = await fetch('http://transcendance:8080/api/v2/user/all')
|
||||
.then( x => x.json() );
|
||||
@@ -56,16 +55,6 @@
|
||||
console.log({...myFriends})
|
||||
};
|
||||
|
||||
let cherif;
|
||||
const fetchAFriend = async() => {
|
||||
cherif = await fetch('http://transcendance:8080/api/v2/network/myfriends/chbadad')
|
||||
.then( x => x.json() );
|
||||
console.log('got Cherif ')
|
||||
console.log(cherif)
|
||||
// console.log({...cherif})
|
||||
};
|
||||
|
||||
|
||||
const fetchRequestsMade = async() => {
|
||||
requestsMade = await fetch('http://transcendance:8080/api/v2/network/pending')
|
||||
.then( x => x.json() );
|
||||
@@ -108,9 +97,9 @@
|
||||
|
||||
const areWeFriends = async(aUsername) => {
|
||||
console.log("Are We Friends?")
|
||||
friendshipStatusFull = undefined;
|
||||
friendshipStatusFull = await fetch(`http://transcendance:8080/api/v2/network/myfriends/${aUsername}`)
|
||||
.then( x => x.json());
|
||||
|
||||
};
|
||||
|
||||
const viewAUser = async(aUsername) => {
|
||||
@@ -127,7 +116,6 @@
|
||||
|
||||
};
|
||||
|
||||
|
||||
const acceptFriendRequest = async(relationshipId) => {
|
||||
console.log('accept friend request')
|
||||
friendshipFetch = undefined;
|
||||
@@ -135,15 +123,17 @@
|
||||
friendshipFetch = await fetch(`http://transcendance:8080/api/v2/network/myfriends/${relationshipId}/accept`, {
|
||||
method: "PATCH"})
|
||||
.then( x => x.json());
|
||||
// maybe not the most robust things, not super reusable cuz it depends on outside vars but works for now...
|
||||
await areWeFriends(usernameBeingViewed);
|
||||
};
|
||||
|
||||
const unfriend = async(relationshipId) => {
|
||||
console.log('Unfriend')
|
||||
friendshipFetch = undefined;
|
||||
// PATCH http://transcendance:8080/api/v2/network/myfriends/:relationshipId/accept
|
||||
friendshipFetch = await fetch(`http://transcendance:8080/api/v2/network/myfriends/${relationshipId}`, {
|
||||
method: "DELETE"})
|
||||
.then( x => x.json());
|
||||
await areWeFriends(usernameBeingViewed);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user