Browse Source

search

pull/92/head
jingxun 2 years ago
parent
commit
13ed202979
  1. 21
      day23/githbu-search/src/components/Search/index.jsx

21
day23/githbu-search/src/components/Search/index.jsx

@ -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" />&nbsp;<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" />&nbsp;
<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…
Cancel
Save