Created
March 23, 2019 11:29
-
-
Save madan712/2c41443206d5e4cb586814e8c7343ef5 to your computer and use it in GitHub Desktop.
App.js - Spring Boot + ReactJS hello world example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {Component} from 'react'; | |
import './App.css'; | |
import axios from 'axios'; | |
class App extends Component { | |
constructor(props) { | |
super(props); | |
this.state = {message: ''}; | |
} | |
componentDidMount() { | |
const url = 'http://localhost:8080/sayhello?name=Java'; | |
axios.get(url).then(response => { | |
console.log('response : '); | |
console.log(response); | |
this.setState({message: response.data}); | |
}).catch(error => { | |
console.log('error : '); | |
console.log(error); | |
}); | |
} | |
render() { | |
return ( | |
<div className="App"> | |
Message : {this.state.message} | |
</div> | |
); | |
} | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment