ok so the problem seems to be that i was sending a username not an ID (which is unique), so i made a way to do that, bu t it's still a work in progress figuring out the restults
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
import Button from "../../pieces/Button.svelte";
|
import Button from "../../pieces/Button.svelte";
|
||||||
|
|
||||||
let errors = {friendRequest: '',};
|
let errors = {friendRequest: '',};
|
||||||
let set = {friendUsername: '',}
|
let set = {friendUsername: '', friendId: Number}
|
||||||
|
|
||||||
let user;
|
let user;
|
||||||
let myFriends;
|
let myFriends;
|
||||||
@@ -93,14 +93,18 @@
|
|||||||
console.log('friend is ')
|
console.log('friend is ')
|
||||||
console.log(set.friendUsername)
|
console.log(set.friendUsername)
|
||||||
|
|
||||||
|
set.friendId = allUsers.find(f => f.username === set.friendUsername).id
|
||||||
|
console.log('friend found: ' + set.friendId)
|
||||||
|
|
||||||
// ok this version works
|
// ok this version works
|
||||||
// ok not really, requesterId and all that is good but...
|
// ok not really, requesterId and all that is good but...
|
||||||
|
// seems like i actually have to send IDs
|
||||||
sentFriendRequest = await fetch("http://transcendance:8080/api/v2/network/myfriends", {
|
sentFriendRequest = await fetch("http://transcendance:8080/api/v2/network/myfriends", {
|
||||||
method : "POST",
|
method : "POST",
|
||||||
headers: { 'Content-Type': 'application/json'},
|
headers: { 'Content-Type': 'application/json'},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
"requesterId": user.username,
|
"requesterId": user.id,
|
||||||
"addresseeId": set.friendUsername,
|
"addresseeId": set.friendId,
|
||||||
"status": r
|
"status": r
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user