Skip to content

Commit

Permalink
Resolve invalid operand and await lint errors in categoryRoutes
Browse files Browse the repository at this point in the history
  • Loading branch information
LillianHo5 committed May 27, 2024
1 parent d0a9a23 commit f117254
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions admin-portal-frontend/src/app/components/categoryRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ export type Category = {
// Gets and returns all categories from API
export const getAllCategories = async () => {
try {
const url = process.env.API_URL + "/categories";

if (!url) {
if (!process.env.API_URL) {
throw new Error("API URL is not defined");
}

const url = `${process.env.API_URL}/categories`;

const response = await fetch(url);
const data = (await response.json()).categories as Category;

Expand All @@ -32,13 +32,13 @@ export const deleteCategory = async (itemId: string) => {
throw new Error("API URL is not defined");
}

const url = process.env.API_URL + `/categories/${itemId}`;
const url = `${process.env.API_URL}/categories/${itemId}`;

if (!url) {
throw new Error("API URL is not defined");
}

fetch(url, {
await fetch(url, {
method: "DELETE",
});
} catch (error) {
Expand All @@ -53,13 +53,13 @@ export const deletePage = async (itemId: string, title: string) => {
throw new Error("API URL is not defined");
}

const url = process.env.API_URL + `/categories/${itemId}/${title}`;
const url = `${process.env.API_URL}/categories/${itemId}/${title}`;

if (!url) {
throw new Error("API URL is not defined");
}

fetch(url, {
await fetch(url, {
method: "PUT",
});
} catch (error) {
Expand Down

0 comments on commit f117254

Please sign in to comment.