room load old message but pbm to read them
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
console.log("formData:", formData);
|
||||
|
||||
// send the new room
|
||||
const response = await fetch('/api/v2/chat/join', {
|
||||
const response = await fetch('/api/v2/chat/create', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(formData),
|
||||
|
||||
@@ -18,23 +18,28 @@
|
||||
.then(resp => resp.json())
|
||||
.then(data =>
|
||||
{
|
||||
console.log(data.rooms);
|
||||
console.log("data.rooms:", data.rooms);
|
||||
for (let room of data.rooms)
|
||||
console.log(room.name);
|
||||
rooms = data.rooms;
|
||||
});
|
||||
|
||||
/*
|
||||
function get_room_messages()
|
||||
{
|
||||
console.log("in get_room_messages");
|
||||
const messages = fetch('/api/v2/chat/messages')
|
||||
.then(resp => resp.json())
|
||||
.then(data =>
|
||||
{
|
||||
console.log(data.messages);
|
||||
msgs.update(msgs => [...msgs, { name: name, message: message }]);
|
||||
msgs.update(msgs => msgs.concat(data.messages));
|
||||
});
|
||||
layout = "room";
|
||||
}
|
||||
function test() {
|
||||
console.log("test");
|
||||
}
|
||||
/*
|
||||
*/
|
||||
|
||||
</script>
|
||||
@@ -68,7 +73,7 @@
|
||||
<p>rooms are loaded...</p>
|
||||
{:then}
|
||||
{#each rooms as room}
|
||||
<Button bind:layout new_layout="room" my_class="list">
|
||||
<Button my_class="list" on_click={get_room_messages}>
|
||||
{room.name}
|
||||
</Button>
|
||||
{/each}
|
||||
|
||||
Reference in New Issue
Block a user