Skip to content

Commit

Permalink
Product Api Udated
Browse files Browse the repository at this point in the history
  • Loading branch information
swarnendu19 committed Aug 22, 2024
1 parent 476d828 commit 95dab18
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/controllers/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const getlatestProducts = asyncHandler(async (req, res, next) => {

export const getSingleProduct = asyncHandler(async (req, res, next) => {
let product;
const id = req.params.id;
const id = req.params.id.trim();
const key = `product-${id}`;
product = await redis.get(key);

Expand Down Expand Up @@ -104,7 +104,7 @@ export const getlatestProducts = asyncHandler(async (req, res, next) => {
description,
stock,
category: category.toLowerCase(),
photo: photosURL,
photos: photosURL,
})

await invalidateCache({product: true, admin: true})
Expand Down Expand Up @@ -135,8 +135,8 @@ export const updateProduct = asyncHandler(
await deleteFromCloudinary(ids);

// Use Mongoose's `set` method to properly update the DocumentArray
product.set({ photos: photosURL });
}
product.set({ photos: photosURL }); // This method ensures correct typing
}

if (name) product.name = name;
if (price) product.price = price;
Expand Down

0 comments on commit 95dab18

Please sign in to comment.