Skip to content

Commit

Permalink
Update API URLs in work.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Gilles-Lucien committed Jan 9, 2024
1 parent aff82c5 commit 1ce38ba
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions FrontEnd/scripts/work.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
// import functions from edit
import { checkToken, getWorksModal, handleEditButtonClick, getCategoriesModal } from "./edit.js";

// API URL variable
const API_URL = "http://localhost:5678/api";

// function to add a work element to the gallery
function addWorkElement(work, gallery) {
const workElement = document.createElement("figure");
Expand All @@ -32,7 +35,7 @@ function addWorkElement(work, gallery) {
// async function to get the works from the API
async function getWorks() {
try {
const response = await fetch("http://localhost:5678/api/works");
const response = await fetch(`${API_URL}/works`);
const works = await response.json();
const gallery = document.querySelector(".gallery");
gallery.innerHTML = "";
Expand Down Expand Up @@ -60,9 +63,10 @@ function addCategory(category, filtersDiv) {
}

// async function to get the categories filters from the API

async function getCategories() {
try {
const response = await fetch("http://localhost:5678/api/categories");
const response = await fetch(`${API_URL}/categories`);
const categories = await response.json();
categories.unshift({ id: "all", name: "Tous" });

Expand Down

0 comments on commit 1ce38ba

Please sign in to comment.