52 lines
885 B
JavaScript
52 lines
885 B
JavaScript
|
let url = "https://jsonplaceholder.typicode.com/posts";
|
||
|
|
||
|
|
||
|
async function asd(url) {
|
||
|
try{
|
||
|
let result = await fetch(url);
|
||
|
let jsadatszerkezet = await result.json();
|
||
|
console.log(jsadatszerkezet);
|
||
|
} catch {
|
||
|
console.log("ERROR");
|
||
|
} finally {
|
||
|
console.log("END");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//asd(url);
|
||
|
|
||
|
|
||
|
async function name(url) {
|
||
|
fetch(url, {
|
||
|
method: 'PUT',
|
||
|
headers: {
|
||
|
'Content-Type': 'application/json',
|
||
|
},
|
||
|
|
||
|
body: JSON.stringify({
|
||
|
name: "Szabó Márton",
|
||
|
email: "digivagyok@gmail.com"
|
||
|
}),
|
||
|
})
|
||
|
}
|
||
|
|
||
|
|
||
|
class Szemely{
|
||
|
#nev;
|
||
|
constructor(nev){
|
||
|
this.#nev = nev;
|
||
|
}
|
||
|
|
||
|
get nev(){
|
||
|
return this.#nev;
|
||
|
}
|
||
|
|
||
|
set nev(ujnev){
|
||
|
this.#nev = ujnev;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
let digi = new Szemely("Digi");
|
||
|
|
||
|
digi.nev = "Szabó Márton";
|
||
|
console.log(digi.nev);
|