added asd

This commit is contained in:
szabomarton
2024-11-12 12:48:08 +01:00
parent 1784bc7fee
commit 262a940747
5 changed files with 39 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
const url = "https://jsonplaceholder.typicode.com/posts";
async function main() {
let xhttp = new XMLHttpRequest();
xhttp.open("GET", url, true);
xhttp.onreadystatechange = async function(){
if (xhttp.readyState === 4){
if (xhttp.status === 200){
let sol = await xhttp.responseText;
//let sol = await JSON.parse(JSON.stringify(xhttp.responseText));
console.log(`Sikeres kérés: ${sol}`);
} else if(xhttp.status === 404){
console.log("Az erőforrás nem található - 404 hibakód");
} else{
console.error(`Hiba történt, státuszkód: ${xhttp.status}`);
}
}
}
xhttp.send();
}
main();