feat(footer):Lendo os dados da api.

This commit is contained in:
Savio Carvalho Moraes 2022-12-13 21:41:36 -03:00
parent 27d740563c
commit 3dc506b33c

View File

@ -8,6 +8,9 @@ export default class Footer {
async init() {
await this.selectors();
// this.onUpdate();
await this.pegarInfo(
"https://m3academy.myvtex.com/api/catalog_system/pub/products/search/?fq=productClusterIds:319"
);
}
async selectors() {
@ -37,4 +40,19 @@ export default class Footer {
slidesToScroll: 1,
});
}
produto(data) {
return {
imagem: data["items"][0]["images"][0]["imageUrl"],
nome: data["productName"],
tamanho: data["items"].map((val) => val["name"]),
};
}
async pegarInfo(url, tratamento) {
const response = await fetch(url);
//console.log(response);
const data = await response.json();
//console.log(data);
const Items = data.map((val) => this.produto(val));
console.log(Items);
}
}