Posted on 13/03/2023 10:27:26
Hi Nicolai.
More context: The user visits a product page. Where you can buy the product in single pieces or in bundles. To Bundle look up take quite a while. So we fetch that async after internal page load. I fetch them through standard fetch in javascript. (In this case vue.js)
let requestUrl = `/Default.aspx?ID=1100&ICC_itemId=${productNo}`;
fetch(requestUrl)
.then(response => response.json())
.then(response => {
...
})
The page I'm fetching is has an ICC app as content with this template:
@{
int x = 0;
bool hasPages = !String.IsNullOrWhiteSpace(GetString("Ecom:IntegrationCustomerCenter.Paging.HasPages")) ? true : false;
string nextPage = "";
if(hasPages && GetInteger("Ecom:IntegrationCustomerCenter.Paging.CurrentPage") < GetInteger("Ecom:IntegrationCustomerCenter.Paging.NumPages")) {
nextPage = GetString("Ecom:IntegrationCustomerCenter.Paging.Forward.URL");
}
}
{
"bundleCount": @GetLoop("Ecom:IntegrationCustomerCenter.BundleLoop").Count(),
"nextPage": "@nextPage",
"currentPage": @GetInteger("Ecom:IntegrationCustomerCenter.Paging.CurrentPage"),
"bundles": [
@foreach(var bundle in GetLoop("Ecom:IntegrationCustomerCenter.BundleLoop")) {
x++;
if(x > 1) {
<text>,</text>
}
<text>
{
"bundleNo": "@bundle.GetString("BundleNo")",
"thickness": "@bundle.GetString("Thickness")",
"length": "@bundle.GetString("Length")",
"width": "@bundle.GetString("Width")",
"stock": {
"warehouse": "@bundle.GetString("Stock")",
"sea": "@bundle.GetString("StockSea")",
"units": "@bundle.GetString("StockUnits")",
"seaUnits": "@bundle.GetString("StockSEAUnits")"
}
}
</text>
}
]
}