jingxun
2 years ago
1 changed files with 15 additions and 6 deletions
@ -1,14 +1,23 @@ |
|||
import axios from 'axios'; |
|||
import React, { Component } from 'react' |
|||
|
|||
export default class Search extends Component { |
|||
render() { |
|||
return ( |
|||
<section className="jumbotron"> |
|||
<h3 className="jumbotron-heading">Search Github Users</h3> |
|||
<div> |
|||
<input type="text" placeholder="enter the name you search" /> <button>Search</button> |
|||
</div> |
|||
</section> |
|||
) |
|||
<h3 className="jumbotron-heading">Search Github Users</h3> |
|||
<div> |
|||
<input ref={c => this.user = c} type="text" placeholder="enter the name you search" /> |
|||
<button onClick={this.search}>Search</button> |
|||
</div> |
|||
</section> |
|||
); |
|||
} |
|||
search = () => { |
|||
const { value: keyword } = this.user; |
|||
axios.get(`http://localhost:3000/api1/search/users?q=${keyword}`).then( |
|||
response => { console.log(response.data); }, |
|||
error => { console.log(error); } |
|||
) |
|||
}; |
|||
} |
|||
|
Loading…
Reference in new issue