-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
37 lines (34 loc) · 1.49 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const axios = require("axios");
const accountDomain = "https://accountName.myvtex.com";
axios
.get(`${accountDomain}/api/catalog_system/pub/category/tree/2/`)
.then((response) => {
let htmlMenu = "";
Array.from(response.data).forEach((department) => {
htmlMenu += `<li class="nav__submenu__list-item nav__lvl-2 has-submenu">
<a title="${department.name}" href="${department.url.replace(
accountDomain,
""
)}">${department.name}</a>
<div class="nav__submenu-category-subcategory">`;
Array.from(department.children).map((category) => {
htmlMenu += `
<div class="nav__submenu-category-subcategory-content-itens">
<h5 class="nav__submenu-category-subcategory-content-title">${category.name}</h5>`;
Array.from(category.children).map((subCategory) => {
htmlMenu += `<a href="${subCategory.url.replace(
accountDomain,
""
)}" class="sublink">${subCategory.name}</a>`;
});
htmlMenu += `<a href="${category.url.replace(
accountDomain,
""
)}" class="sublink link-down">Ver todos</a>`;
htmlMenu += `</div>`;
});
htmlMenu += `</div>`;
htmlMenu += `</li>`;
});
console.log(htmlMenu);
});