Skip to content

Commit

Permalink
Merge pull request #32 from Crudzaso/feature/1361/lottery-results
Browse files Browse the repository at this point in the history
add a environment variable to send a request to the lotteries api
  • Loading branch information
DiegoAndresRamirez authored Nov 4, 2024
2 parents 22e02f3 + 718a3f5 commit 2750a0f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion resources/js/Pages/LotteryResults.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,17 @@ const cardStyle = computed(() => ({
const fetchLotteryResults = async () => {
try {
const response = await fetch('https://apilotteries.onrender.com/api/lotteries');
const response = await fetch('https://apilotteries.onrender.com/api/lotteries', {
method: 'GET',
headers: {
'Authorization': `Bearer ${import.meta.env.VITE_TOKEN_LOTTERIES_API}`
}
});
if (!response.ok) {
throw new Error('Network response was not ok');
}
const data = await response.json();
lotteryResults.value = data.data.slice(0, 11).map(lottery => ({
name: lottery.firstH1,
Expand All @@ -44,6 +54,8 @@ const fetchLotteryResults = async () => {
}
};
onMounted(() => {
fetchLotteryResults();
});
Expand Down

0 comments on commit 2750a0f

Please sign in to comment.