项目作者: SOURAV-ROY
项目描述 :
Google Custom Search Engine By ReactJS💚✔
高级语言: JavaScript
项目地址: git://github.com/SOURAV-ROY/google-clone.git
Use the package manager npm to install
npm install react-router-dom
npm install @material-ui/core
npm install @material-ui/icons
Google Custom Search
const UseGoogleSearch = (term) => {
const [data, setData] = useState(null);
useEffect(() => {
const fetchData = async () => {
fetch(`https://www.googleapis.com/customsearch/v1?key=${API_KEY}&cx=${CONTEXT_KEY}&q=${term}`)
.then(response => response.json())
.then(result => {
setData(result)
})
}
fetchData().then(res => {
console.log(res);
}).catch(error => {
console.log(error);
});
}, [term]);
return {data};
};