

function re_direct () {
    const user_name = document.getElementById('username').value.trim();
    const session_id = document.getElementById('session_id').value.trim();
    const encodedUser = encodeURIComponent(user_name);
    const encodedSession = encodeURIComponent(session_id);

    window.location.href = `/${encodedSession}/${encodedUser}`;
    
}

async function addWord() {
    const word = document.getElementById('word').value.trim();
    const imposterWord = document.getElementById('imposterWord').value.trim();

    const data = {
        word: word,
        imposterWord: imposterWord,
    }
    const res = await fetch (`/api/words/add`, {
        method: 'PUT',
        headers: {
            'Content-Type': 'application/json',
        },
        body: JSON.stringify(data)
    });
}
