import React from 'react'; import axios from 'axios'; import { useState } from 'react'; import { API_ROUTES, APP_ROUTES } from '../utils/constants'; import { Link, useNavigate } from 'react-router-dom'; const SignUp = () => { const navigate = useNavigate() const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [firstname, setFirstname] = useState(''); const [lastname, setLastname] = useState(''); const [isLoading, setIsLoading] = useState(false); const signUp = async () => { try { setIsLoading(true); const response = await axios({ method: 'POST', url: API_ROUTES.SIGN_UP, data: { email, password, firstname, lastname } }); if (!response?.data?.token) { console.log('Something went wrong during signing up: ', response); return; } navigate(APP_ROUTES.SIGN_IN); } catch (err) { console.log('Some error occured during signing up: ', err); } finally { setIsLoading(false); } }; return ( // SIGN UP FORM TEMPLATE ); } export default SignUp;
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter