Table of contents
(XMLHttpRequest)[https://developer.mozilla.org/ko/docs/Web/API/XMLHttpRequest]
const url = "https://dummyjson.com/products";
const req = new XMLHttpRequest();
let div = document.querySelector("div");
req.onload = (e) => {
const datas = req.response; // not responseText
for (data of datas.products) {
let { brand, parent } = data;
div.innerHTML += `brand: ${brand}, <br> parent: ${parent}<br><hr>`;
console.log(brand, parent);
}
};
req.open("GET", url);
req.responseType = "json";
req.send();