This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server.use( | |
rest.post('/login', (req, res, ctx) => { | |
const {email, password} = req.body as DefaultBodyType & { | |
email: string | |
password: string | |
} | |
if ( | |
email === '[email protected]' && | |
password === 'Aa12345678$' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
setIsFetching(true) | |
const apiURL = `${API_URL}/authentication/signin` | |
const strBody: BodyInit = `{"email":"${email}","password":"${password}"}` | |
const response: Response = await fetch(apiURL, { | |
method: 'POST', | |
mode: 'cors', | |
headers: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const signIn = createAsyncThunk( | |
'authentication/signin', | |
async ({email, password}: thunkArgs) => { | |
const apiURL = `${API_URL}/authentication/signin` | |
const strBody: BodyInit = `{"email":"${email}","password":"${password}"}` | |
const response = await fetch(apiURL, { | |
method: 'POST', | |
mode: 'cors', | |
headers: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {SyntheticEvent} from 'react' | |
const Login = () => { | |
const handleSubmit = async (evt: SyntheticEvent) => { | |
evt.preventDefault() | |
const target = evt.target as HTMLFormElement | |
const elements = target.elements as typeof target.elements & { | |
email: {value: string} | |
password: {value: string} |