forked from adityabisoi/github-rest-api-v3
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApp.js
More file actions
34 lines (27 loc) · 718 Bytes
/
App.js
File metadata and controls
34 lines (27 loc) · 718 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import './App.css';
import axios from 'axios'
import {useState} from 'react'
const App = () => {
const [username,setUsername] = useState('')
const updateUsername=(e)=>{
setUsername(e.target.value)
}
const getDetails=()=>{
axios.get(`https://api.github.com/users/${username}/repos`)
.then(data=>console.log(data))
}
const sendUsername=(e)=>{
e.preventDefault()
getDetails(username)
}
return(
<div className="App">
<form onSubmit={sendUsername}>
<label>Enter your github username</label>
<input type='text' value={username} onChange={updateUsername}/>
<button type='submit'>Search</button>
</form>
</div>
)
}
export default App;