wip db request with array not working

This commit is contained in:
simplonco
2023-01-08 20:21:19 +01:00
parent f4dc5cde53
commit ebbd5ff530
8 changed files with 214 additions and 120 deletions

View File

@@ -22,7 +22,6 @@
let formData = {
room_name: room_name,
room_type: room_type,
room_password: room_password,
};
console.log("formData:", formData);

View File

@@ -17,9 +17,46 @@
rooms = data.rooms;
});
function join_rooms()
function join_rooms(evt)
{
console.log("inside join_rooms");
let room_name = {
room_name: evt.target.innerText,
}
const messages = fetch('/api/v2/chat/join',
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(room_name),
})
.then(resp => resp.json())
.then(data =>
{
console.log(data);
// data.messages.forEach(function(item) {
// if (item.name === user.username) {
// item.name = "me";
// }
// });
// msgs.update(msgs => msgs.concat(data.messages));
});
/*
const messages = fetch('/api/v2/chat/messages')
.then(resp => resp.json())
.then(data =>
{
console.log(data.messages);
data.messages.forEach(function(item) {
if (item.name === user.username) {
item.name = "me";
}
});
msgs.update(msgs => msgs.concat(data.messages));
});
layout = "room";
*/
}
</script>