added orai
This commit is contained in:
parent
6dc5052873
commit
71a97bc404
BIN
24_10_14/24_10_14 - Frontend.pptx
Normal file
BIN
24_10_14/24_10_14 - Frontend.pptx
Normal file
Binary file not shown.
34
24_10_14/fetch.js
Normal file
34
24_10_14/fetch.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
let url = "https://jsonplaceholder.typicode.com/users/";
|
||||
|
||||
fetch(url)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
document.getElementById("username").innerHTML += data[2].name;
|
||||
document.getElementById("email").innerHTML += data[1].email;
|
||||
})
|
||||
.catch(data => console.log(data));
|
||||
|
||||
// post
|
||||
let path = "response.json";
|
||||
fetch(url, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
name: "Példa Péter",
|
||||
email: "pelda_peter@gmail.com"
|
||||
}),
|
||||
}).then(response => response.json()).then(data => console.log(data));
|
||||
|
||||
//PUT
|
||||
fetch(url, {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
name: "Példa Péter",
|
||||
email: "pelda_peter@gmail.com"
|
||||
}),
|
||||
}).then(response => response.json()).then(data => console.log(data));
|
13
24_10_14/index.html
Normal file
13
24_10_14/index.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<script src="fetch.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<p id="username">Felhasználónév: </p>
|
||||
<p id="email">Email cím: </p>
|
||||
</body>
|
||||
</html>
|
57
24_10_14/promise_exercise.js
Normal file
57
24_10_14/promise_exercise.js
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
let mypromise = new Promise((resolve, reject) => {
|
||||
let istrue = false;
|
||||
if (istrue){
|
||||
resolve("resolved");
|
||||
} else {
|
||||
reject("rejected");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mypromise.then((resolve) => {
|
||||
console.log(`resolved: ${resolve}`);
|
||||
}).catch((reject) => {
|
||||
console.log(`rejected: ${reject}`);
|
||||
});
|
||||
*/
|
||||
|
||||
function elso(value){
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
console.log(value);
|
||||
resolve(value);
|
||||
}, 3000);
|
||||
});
|
||||
}
|
||||
|
||||
function masodik(value){
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
console.log(value);
|
||||
resolve(value);
|
||||
}, 2000);
|
||||
});
|
||||
}
|
||||
|
||||
function harmadik(value){
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
console.log(value);
|
||||
resolve("Minden lépés teljesítve");
|
||||
}, 1000);
|
||||
});
|
||||
}
|
||||
|
||||
function asd(){
|
||||
elso(1)
|
||||
.then((value) => masodik((value + 1)))
|
||||
.then((value) => harmadik((value + 1)))
|
||||
.then((message) => {console.log(message);});
|
||||
}
|
||||
|
||||
let num = 0;
|
||||
setTimeout(() => {console.log("Ez az üzenet 3 másodperc után megjelenik.")}, 3000);
|
||||
let ismetles = setInterval(() => {num++;console.log("Ez az üzenet 3 másodpercenként megjelenik.");}, 3000);
|
||||
clearInterval(ismetles);
|
||||
|
0
24_10_14/response.json
Normal file
0
24_10_14/response.json
Normal file
Loading…
Reference in New Issue
Block a user