Added useApi hook.

This commit is contained in:
Mike Cao 2022-02-22 23:52:31 -08:00
parent 7bd49e6caf
commit d19b6b5a82
22 changed files with 59 additions and 59 deletions

View file

@ -10,7 +10,7 @@ import FormLayout, {
FormRow,
} from 'components/layout/FormLayout';
import Icon from 'components/common/Icon';
import usePost from 'hooks/usePost';
import useApi from 'hooks/useApi';
import { setItem } from 'lib/web';
import { AUTH_TOKEN } from 'lib/constants';
import { setUser } from 'store/app';
@ -31,12 +31,12 @@ const validate = ({ username, password }) => {
};
export default function LoginForm() {
const post = usePost();
const { post } = useApi();
const router = useRouter();
const [message, setMessage] = useState();
const handleSubmit = async ({ username, password }) => {
const { ok, status, data } = await post('/api/auth/login', {
const { ok, status, data } = await post('/auth/login', {
username,
password,
});