GET https://api.reflowhq.com/v2/stores//products/ GET https://api.reflowhq.com/v2/stores//categories/ Friendly Penguin // Print the 20 newest products let products = await fetch( "https://api.reflowhq.com/v2/stores/267418190/products/" ).then((r) => r.json()); console.log(products.data); // Print the 10 oldest products let products = await fetch( "https://api.reflowhq.com/v2/stores/267418190/products/?order=date_asc&perpage=10" ).then((r) => r.json()); console.log(products.data); // Print all the products from a category let products = await fetch( "https://api.reflowhq.com/v2/stores/267418190/products/?category=123456789" ).then((r) => r.json()); console.log(products.data); // 1. Fetch all categories and print their names let categories = await fetch( "https://api.reflowhq.com/v2/stores/267418190/categories" ).then((r) => r.json()); console.log(categories.map((c) => c.name)); // 2. If your store has subcategories, a bit more work is needed let printCategoryNames = (categories) => { for (let c of categories) { console.log(c.name); printCategoryNames(c.subcategories); } }; // 2.1 Fetch all categories and print their names recursively let categories = await fetch( "https://api.reflowhq.com/v2/stores/267418190/categories" ).then((r) => r.json()); printCategoryNames(categories); // 2.2 Fetch only a specific category and its subcategories, and print their names let categories = await fetch( "https://api.reflowhq.com/v2/stores/267418190/categories?root-category=177837305" ).then((r) => r.json()); printCategoryNames(categories);

© UFTS 2024. All Rights Reserved