update fetch calls in frontend

This commit is contained in:
Sura Hanna 2024-10-16 18:07:03 -04:00
parent 319f83afaf
commit 0b6d992a71
3 changed files with 6 additions and 6 deletions

View File

@ -87,7 +87,7 @@ function formatTime(date) {
async function fetchAllEvents() { async function fetchAllEvents() {
console.log("fetching events"); console.log("fetching events");
const response = await fetch('http://localhost:8080/api/events'); const response = await fetch('/api/events');
const allEvents = await response.json(); const allEvents = await response.json();
const resourcesContainer = document.getElementById('resources-container'); const resourcesContainer = document.getElementById('resources-container');
@ -128,7 +128,7 @@ function updateFontSize(elementId) {
async function fetchAndDisplayQuote() { async function fetchAndDisplayQuote() {
try { try {
// Update the endpoint if you created a new one // Update the endpoint if you created a new one
const response = await fetch('http://localhost:8080/api/quotes'); // or '/api/quotes/random' const response = await fetch('/api/quotes'); // or '/api/quotes/random'
if (response.ok) { if (response.ok) {
const randomQuote = await response.json(); const randomQuote = await response.json();
@ -161,7 +161,7 @@ function displayDefaultQuote() {
// Fetch Current Weather // Fetch Current Weather
async function fetchWeather() { async function fetchWeather() {
const response = await fetch('http://localhost:8080/api/weather'); const response = await fetch('/api/weather');
const data = await response.json(); const data = await response.json();
if (data.cod === 200) { if (data.cod === 200) {
const temperature = data.main.temp; const temperature = data.main.temp;
@ -190,7 +190,7 @@ function displayTime() {
async function fetchSlideshowImages() { async function fetchSlideshowImages() {
try { try {
const response = await fetch('http://localhost:8080/api/slideshow'); const response = await fetch('/api/slideshow');
if (!response.ok) { if (!response.ok) {
throw new Error('Failed to fetch slideshow images'); throw new Error('Failed to fetch slideshow images');
} }
@ -204,7 +204,7 @@ async function fetchSlideshowImages() {
function createSlideshowElement(src) { function createSlideshowElement(src) {
const img = document.createElement('img'); const img = document.createElement('img');
// img.src = src; // img.src = src;
img.src = `http://localhost:8080${src}`; img.src = `${src}`;
img.className = 'slideshow-img'; img.className = 'slideshow-img';
img.style.width = '100%'; img.style.width = '100%';
img.style.maxHeight = '100vh'; img.style.maxHeight = '100vh';

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long