File size: 1,179 Bytes
a94a366
 
 
 
5815d8e
 
 
 
 
 
 
 
 
 
 
 
 
a94a366
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5815d8e
 
 
 
a94a366
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import logo from './logo.svg';
import './App.css';

function App() {
  const handleButtonClick1 = () => {
    fetch('http://localhost:5000/')
      .then((response) => response.json())
      .then((data) => console.log(data.message))
      .catch((error) => console.error('An error occurred:', error));
  };

  const handleButtonClick2 = () => {
    fetch('http://localhost:5000/api/')
      .then((response) => response.json())
      .then((data) => console.log(data.message))
      .catch((error) => console.error('An error occurred:', error));
  };
  return (
    <div className="App">
      <header className="App-header">
        <img src={logo} className="App-logo" alt="logo" />
        <p>
          Edit <code>src/App-1.js</code> and save to reload.
        </p>
        <a
          className="App-link"
          href="https://reactjs.org"
          target="_blank"
          rel="noopener noreferrer"
        >
          Learn React -- - 10
        </a>
        <div>
          <button onClick={handleButtonClick1}>Ping /</button>
          <button onClick={handleButtonClick2}>Ping /api</button>
        </div>
      </header>
    </div>
  );
}

export default App;