import React, { useRef } from "react" import { Link, useHistory } from "react-router-dom" export const Register = () => { const firstName = useRef() const lastName = useRef() const username = useRef() const bio = useRef() const password = useRef() const verifyPassword = useRef() const passwordDialog = useRef() const history = useHistory() const handleRegister = (e) => { e.preventDefault() if (password.current.value === verifyPassword.current.value) { const newUser = { "username": username.current.value, "first_name": firstName.current.value, "last_name": lastName.current.value, "password": password.current.value } return fetch("http://127.0.0.1:8000/register", { method: "POST", headers: { "Content-Type": "application/json", "Accept": "application/json" }, body: JSON.stringify(newUser) }) .then(res => res.json()) .then(res => { if ("token" in res) { localStorage.setItem("sf_token", res.token) history.push("/") } }) } else { passwordDialog.current.showModal() } } return (
Passwords do not match

Register an account