Kinda fix networks

This commit is contained in:
Lucas
2026-01-31 17:52:49 +10:00
parent f70af3c4ea
commit 65d8c7d5e2
13 changed files with 97 additions and 29 deletions

View File

@@ -37,14 +37,14 @@ export const p2privateApi = {
},
async createMessage(from, to, content, medias){
const data = {"from":from, "to":to, "content":content, "medias":medias}
const data = {"content":content, "medias":medias}
const requestOptions = {
method: 'POST',
headers: {'Content-Type': 'application/json',},
body: JSON.stringify(data),
};
try {
const response = await fetch(p2privateApiUrl+"/messages", requestOptions);
const response = await fetch(p2privateApiUrl+"/messages/"+from+"/"+to, requestOptions);
if (!response.ok) {
const errorText = await response.text();
throw new Error(`Error fetching posts: ${response.status} - ${errorText}`);
@@ -59,6 +59,21 @@ export const p2privateApi = {
}
},
async getChat(from, to){
try {
const response = await fetch(p2privateApiUrl+"/messages/"+from+"/"+to)
if (!response.ok) {
const errorText = await response.text();
throw new Error(`Error fetching networks: ${response.status} - ${errorText}`);
}
const result = await response.json()
return result;
} catch (error) {
console.error("Error fetching networks:", error);
throw error;
}
},
// async createPosts(user, content, medias, networks){
// const data = {"user": user, "content": content, "medias": medias, "networks": networks};
// const requestOptions = {