Skip to content

Commit

Permalink
testing wikipedia api
Browse files Browse the repository at this point in the history
  • Loading branch information
milkon19960801 committed May 7, 2021
1 parent b6696fc commit fb09cb7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"@testing-library/jest-dom": "^5.12.0",
"@testing-library/react": "^11.2.6",
"@testing-library/user-event": "^12.8.3",
"axios": "^0.21.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
Expand Down
18 changes: 17 additions & 1 deletion src/components/Search.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
import React, { useState, useEffect } from 'react';
import axios from 'axios';

const Search = () => {
const [term, setTerm] = useState('');

useEffect(() => {
console.log('I RUN IF DATA CHANGES');
// const response = (async () => await axios.get(''))();

const search = async () => {
return await axios.get('https://en.wikipedia.org/w/api.php', {
params: {
action: 'query',
list: 'search',
origin: '*',
format: 'json',
srsearch: term,
},
});
};
const response = search();

console.log(response);
}, [term]);

return (
Expand Down

0 comments on commit fb09cb7

Please sign in to comment.