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