Skip to content

Commit

Permalink
add createChat func on frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
Lopkop committed Feb 29, 2024
1 parent 459f9a3 commit 0c6b6c5
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion frontend/src/components.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,23 @@ async function user_is_logged_in() {
}
}

export {Footer, user_is_logged_in, get_user}
async function createChat(event) {
let user = await get_user()

let response = await fetch("http://localhost:8000/create-chat?username=" + `${user.name}`, {
method: 'POST',
headers: {
"Content-type": "application/json"
}
}).then(response => response.json());
console.log(response)


if (response.status === 201) {
localStorage.chat = response.chat
window.location.pathname = `/chat/${response.name}`;
}
}


export {Footer, user_is_logged_in, get_user, createChat}

0 comments on commit 0c6b6c5

Please sign in to comment.