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:
Me
2022-12-09 05:33:32 +01:00
parent 302ebd674c
commit 58234c8a6c

View File

@@ -4,7 +4,7 @@
import Button from "../../pieces/Button.svelte";
let errors = {friendRequest: '',};
let set = {friendUsername: '',}
let set = {friendUsername: '', friendId: Number}
let user;
let myFriends;
@@ -93,14 +93,18 @@
console.log('friend is ')
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 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", {
method : "POST",
headers: { 'Content-Type': 'application/json'},
body: JSON.stringify({
"requesterId": user.username,
"addresseeId": set.friendUsername,
"requesterId": user.id,
"addresseeId": set.friendId,
"status": r
})
})