Skip to content

Commit 4304715

Browse files
committed
Invoking the greetingv1 api
1 parent 09bf0a8 commit 4304715

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

ui/src/App.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
1+
import React, { useState, useEffect } from 'react';
12
import logo from './logo.svg';
23
import './App.css';
34

45
function App() {
6+
7+
const [currentGreetingV1, setCurrentGreetingV1] = useState('Unknown');
8+
9+
useEffect(() => {
10+
fetch('/api/greeting/v1/').then(res => res.json()).then(data => {
11+
setCurrentGreetingV1(data.message);
12+
})
13+
})
14+
515
return (
616
<div className="App">
7-
<header className="App-header">
8-
<img src={logo} className="App-logo" alt="logo" />
9-
<p>
10-
Edit <code>src/App.js</code> and save to reload.
11-
</p>
12-
<a
13-
className="App-link"
14-
href="https://reactjs.org"
15-
target="_blank"
16-
rel="noopener noreferrer"
17-
>
18-
Learn React
19-
</a>
20-
</header>
17+
<p>The current greeting is {currentGreetingV1}</p>
2118
</div>
2219
);
2320
}

0 commit comments

Comments
 (0)