import React, {useEffect, useState} from "react"; import {Link} from "react-router-dom"; import {useMessage} from "../hooks/message.hook"; import {useHttp} from "../hooks/http.hook"; export const RegisterPage = () => { const {loading, error, request, clearError} = useHttp() const message = useMessage(); const [username, setUsername] = useState( '') const [password, setPassword] = useState( '') const [role, setRole] = useState( '') const registerHandler = async () => { try{ console.log(username, password) const data = await request('/api/create/register', 'POST', {username: username, password: password, role: role}) message(data.message) console.log('Data', data) } catch (e){ } } useEffect(() => { message(error); clearError() },[error, message, clearError]) useEffect(() => { window.M.updateTextFields() }, []) return(