Skip to content

Commit

Permalink
add the api_key in .env
Browse files Browse the repository at this point in the history
  • Loading branch information
ChloeSeclier committed Feb 24, 2025
1 parent c10337b commit f7afbcb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1 +1 @@
API_KEY=ENTER_YOUR_API_KEY
VITE_API_KEY=ENTER_YOUR_API_KEY
9 changes: 3 additions & 6 deletions src/pages/results.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,17 @@ import { ChoicesContext } from '../contexts/choices-context';
import { keyWordTechList } from '../data/keyword-list';
import './results.scss';

const API_KEY = import.meta.env.VITE_API_KEY;

export default function Results() {
const { searchValue, storedChoiceLanguage, isRandom, listSearch, setListSearch } = useContext(ChoicesContext);

useEffect(() => {
if (searchValue) {
// Clear sessionStorage before new search
sessionStorage.setItem('tableSearch', JSON.stringify([]));

//launch the request
fetch(
`https://newsdata.io/api/1/latest?apikey=pub_65232fbbf2a92bccb58b53492c068ed55dc6a&q=${encodeURIComponent(
searchValue,
)}`,
)
fetch(`https://newsdata.io/api/1/latest?apikey=${API_KEY}&q=${encodeURIComponent(searchValue)}`)
.then((response) => response.json())
.then((data) => {
//Filter on keywords "technology", to have more results we check also description
Expand Down

0 comments on commit f7afbcb

Please sign in to comment.