diff --git a/React_Frontend/src/App.js b/React_Frontend/src/App.js index 9626c8f..1a8368b 100644 --- a/React_Frontend/src/App.js +++ b/React_Frontend/src/App.js @@ -4,16 +4,16 @@ import Zoom from 'react-reveal/Zoom'; import Flip from 'react-reveal/Flip' class App extends Component { - constructor() { - super(); - this.state = { + + + state = { dataku: [], }; -} + -klikPost(e){ +klikPost = (e) => { e.preventDefault(); - var url = 'http://localhost:3210/data'; + let url = 'http://localhost:3210/data'; axios.post(url, { nama: this.inputnama.value, usia: this.inputusia.value @@ -28,9 +28,9 @@ klikPost(e){ this.inputusia.value = ''; }; -klikGet(e){ +klikGet = (e) => { e.preventDefault(); - var url = 'http://localhost:3210/data'; + let url = 'http://localhost:3210/data'; axios.get(url) .then((ambilData) => { console.log(ambilData.data); @@ -42,7 +42,7 @@ klikGet(e){ render() { const dataMySQL = this.state.dataku.map((item, index)=>{ - var arrayku = ['Nama: ',item.Nama,', Usia: ', item.Usia, ' th.'].join(' '); + let arrayku = ['Nama: ',item.nama,', Usia: ', item.usia, ' th.'].join(' '); return

{arrayku}

; }) return ( @@ -66,10 +66,10 @@ render() { + onClick={this.klikPost}>POST + onClick={this.klikGet}>GET @@ -83,4 +83,4 @@ render() { } } -export default App; \ No newline at end of file +export default App;