Created
November 3, 2020 17:51
-
-
Save hosseinmd/19156f24d89f59bf438c87b3b6df2bc1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function App() { | |
const [data, setData] = useState([]); | |
const [query, setQuery] = useState('a query for search'); | |
useEffect(() => { | |
const fetchData = async () => { | |
const result = await axios( | |
`http://hn.algolia.com/api/v1/search?query=${query}`, | |
); | |
setData(result.data); | |
}; | |
fetchData(); | |
}, [query]); | |
return ( | |
... | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment