ondc-campaign-sdk
Version:
[](https://www.npmjs.com/package/ondc-campaign-sdk) [](LICENSE) [ • 1.62 kB
text/typescript
export async function fetchLiveCampaignProducts(): Promise<any> {
try {
const response = await fetch("http://localhost:5000/api/campaigns/active");
if (!response.ok) {
throw new Error("Failed to fetch campaign data");
}
const data = await response.json();
return data;
} catch (error) {
console.error("Error fetching campaign products:", error);
return {
_id: "",
campaignName: "",
description: "",
banner: "",
products: [
{
prices: {
regular: {
price: "",
formatted_price: "",
},
final: {
price: "",
formatted_price: "",
},
},
ratings: {
average: "",
total: "",
},
reviews: {
total: "",
},
id: "",
sku: "",
name: "",
description: "",
url_key: "",
base_image: {
small_image_url: "",
medium_image_url: "",
large_image_url: "",
original_image_url: "",
},
images: [
{
small_image_url: "",
medium_image_url: "",
large_image_url: "",
original_image_url: "",
},
],
is_new: "",
is_featured: "",
on_sale: "",
is_saleable: "",
is_wishlist: "",
min_price: "",
price_html: "",
},
],
isActive: "",
createdAt: "",
__v: "",
};
}
}