Advertisement
hamaXD

Untitled

Feb 2nd, 2019
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import axios from 'axios'
  3. import './App.css';
  4.  
  5. class App extends Component {
  6. constructor(){
  7. super()
  8. this.state = {
  9. ans :"",
  10. text:"",
  11. data: []
  12. }
  13.  
  14. }
  15. get =() =>{
  16. axios.get('http://localhost:3001/api/q').then(res => {
  17. console.log(res.data)
  18. this.setState({
  19. data : res.data
  20. })
  21. })
  22. }
  23.  
  24. render() {
  25. return (
  26.  
  27. <center>
  28. <button onClick={this.get}></button>
  29. <h1>{this.state.data}</h1>
  30. </center>
  31. );
  32. }
  33. }
  34.  
  35. export default App;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement