Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react';
- import axios from 'axios'
- import './App.css';
- class App extends Component {
- constructor(){
- super()
- this.state = {
- ans :"",
- text:"",
- data: []
- }
- }
- get =() =>{
- axios.get('http://localhost:3001/api/q').then(res => {
- console.log(res.data)
- this.setState({
- data : res.data
- })
- })
- }
- render() {
- return (
- <center>
- <button onClick={this.get}></button>
- <h1>{this.state.data}</h1>
- </center>
- );
- }
- }
- export default App;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement