Skip to content

Instantly share code, notes, and snippets.

@madan712
Created March 23, 2019 11:29
Show Gist options
  • Save madan712/2c41443206d5e4cb586814e8c7343ef5 to your computer and use it in GitHub Desktop.
Save madan712/2c41443206d5e4cb586814e8c7343ef5 to your computer and use it in GitHub Desktop.
App.js - Spring Boot + ReactJS hello world example
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