test request

This commit is contained in:
Primakov Alexandr Alexandrovich 2024-02-15 16:39:59 +03:00
parent f7a8c9e077
commit a401290920
2 changed files with 24 additions and 4 deletions

View File

@ -48,6 +48,24 @@ export const Journal = () => {
check();
}, []);
const [answer, setAnswer] = useState(null);
const send = async () => {
if (keycloak.authenticated) {
keycloak;
const rq = await fetch(`${getConfigValue("journal.back.url")}/test`, {
headers: {
accept: "application/json",
authorization: `Bearer ${keycloak.token}`,
},
});
const data = await rq.json();
setAnswer(data);
} else {
setAnswer({ message: 'Пользователь не авторизован' })
}
}
const [value, setValue] = useState("");
const handleChange = useCallback(
(event) => {
@ -70,6 +88,10 @@ export const Journal = () => {
return (
<StartWrapper>
<IconButton onClick={send} title="Запрос">
<ArrowImg src={arrow} />
</IconButton>
<pre>{JSON.stringify(answer, null, 4)}</pre>
<form onSubmit={handleSubmit}>
<InputWrapper>
<InputLabel htmlFor="input">Название новой лекции:</InputLabel>

View File

@ -64,12 +64,10 @@ const Input = ({ onStart }) => {
}
export const MainPage = () => {
const [shoList, setShoList] = useState(false);
return (
<MainWrapper>
{!shoList && <Input onStart={() => setShoList(true)} />}
{shoList && <Journal />}
{/* {!shoList && <Input onStart={() => setShoList(true)} />} */}
<Journal />
</MainWrapper>
);
};