some fixes
This commit is contained in:
parent
94ecf9b53f
commit
a40ef56620
@ -3,58 +3,50 @@ import { useState, useEffect } from 'react';
|
||||
import DataService from '../services/DataService';
|
||||
|
||||
export default function Main(props) {
|
||||
function getRandomNumber() {
|
||||
const url = 'http://localhost:8080';
|
||||
const urlRandomNumber = '/getRandomNumber';
|
||||
const urlCalc = '/sum?val1=num1&val2=num2';
|
||||
const urlLength = '/length?name=strName';
|
||||
const urlUpperCase = '/upperCase?word=strWord';
|
||||
|
||||
function get(url2) {
|
||||
fetch(
|
||||
'http://localhost:8080/getRandomNumber',
|
||||
url + url2,
|
||||
{
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
}
|
||||
).then(resp => resp.text()).then(alert);
|
||||
}
|
||||
|
||||
function getRandomNumber() {
|
||||
get(urlRandomNumber);
|
||||
|
||||
}
|
||||
function req_calc() {
|
||||
console.log(num1);
|
||||
fetch(
|
||||
`http://localhost:8080/sum?val1=${num1}&val2=${num2}`,
|
||||
{
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
}
|
||||
).then(resp => resp.text()).then(alert);
|
||||
get(urlCalc.replace("num1", num1).replace("num2", num2));
|
||||
}
|
||||
const [num1, setnum1] = useState('');
|
||||
const [num2, setnum2] = useState('');
|
||||
function valueChanged1(event) {
|
||||
console.log(event.target);
|
||||
setnum1(event.target.value);
|
||||
}
|
||||
function valueChanged2(event) {
|
||||
setnum2(event.target.value);
|
||||
}
|
||||
function req_length() {
|
||||
console.log(num1);
|
||||
fetch(
|
||||
`http://localhost:8080/length?name=${name}`,
|
||||
{
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
}
|
||||
).then(resp => resp.text()).then(alert);
|
||||
get(urlLength.replace("strName", strName));
|
||||
|
||||
}
|
||||
const [name, setName] = useState('');
|
||||
const [strName, setName] = useState('');
|
||||
function valueChangedName(event) {
|
||||
setName(event.target.value);
|
||||
}
|
||||
function req_upperCase() {
|
||||
console.log(num1);
|
||||
fetch(
|
||||
`http://localhost:8080/upperCase?word=${word}`,
|
||||
{
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
}
|
||||
).then(resp => resp.text()).then(alert);
|
||||
get(urlUpperCase.replace("strWord", strWord));
|
||||
}
|
||||
const [word, setWord] = useState('');
|
||||
const [strWord, setWord] = useState('');
|
||||
function valueChangedWord(event) {
|
||||
setWord(event.target.value);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user