Belajar react #1 SignIn dan SIgnUp
sebelum melakukan pembuatan signin signup silahkan bua file src/api.js kemudian letakkan kode ini dedalam file api.js import axios from "axios" ; const API_BASE_URL = "http://localhost:8000/api/v1" ; // Sesuaikan dengan URL backend-mu const api = axios . create ({ baseURL : API_BASE_URL , headers : { "Content-Type" : "application/json" , }, }); export default api ; INI UNTUK SIGNUP import { useState } from "react" ; import { useNavigate , Link } from "react-router-dom" ; import api from "../api" ; // Import konfigurasi API const SignUp = () => { const [ username , setUsername ] = useState ( "" ); const [ password , setPassword ] = useState ( "" ); const [ error , setError ] = useState ( "" ); const navigate = useNavigate (); const handleSubmit = async ( e ) => { e . preventDefault (); setError ( "" ); // R...