Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
TCP/IP
HTTP/ HTTPS
CRUD
REST API
Fetch
async/await
try...catch
11 changes: 11 additions & 0 deletions js/practice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

function sum(a, b) {
let result = 0;

result = a + b;

return result
};

console.log(sum(5, 7));
88 changes: 44 additions & 44 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ const btn = document.querySelector(".js-get-data");
// btn.addEventListener("click", getUrl);

// function getUrl() {
// // return fetch("https://api.monobank.ua/bank/currency");
// return fetch("https://api.monobank.ua/bank/currency");
// return fetch("https://the-cocktail-db.p.rapidapi.com/search.php'");
// // fetch(
// // "https://api.github.com/repos/javascript-tutorial/en.javascript.info/commits"
// // );
// fetch(
// "https://api.github.com/repos/javascript-tutorial/en.javascript.info/commits"
// );
// }

// let promise = fetch(url, {
Expand Down Expand Up @@ -96,70 +96,70 @@ const btn = document.querySelector(".js-get-data");

// try {
// console.log("Start");
// a;
// addEventListener();
// console.log("Finish");
// } catch (err) {
// console.log("Errr");
// }

// try {
// setTimeout(function () {
// da;
// }, 1000);
// setTimeout(function () {
// da;
// }, 1000);
// } catch (err) {
// console.log("Errr");
// console.log("Errr");
// }

// setTimeout(function () {
// try {
// da;
// } catch (err) {
// console.log("Errr");
// }
// try {
// da;
// } catch (err) {
// console.log("Errr");
// }
// }, 1000);

// try {
// da;
// da;
// } catch (err) {
// console.log(err.stack);
// console.log(err.stack); //name, message
// }

// let json = `{"name": "Ann"}`;

// try {
// let user = JSON.parse(json);
// // if (!user.city) {
// // throw new SyntaxError("Нема міста");
// // }
// if (!user.city) {
// throw new SyntaxError("Нема міста");
// }
// console.log("start");
// } catch (err) {
// console.log("Err", err.message);
// } finally {
// console.log("finally");
// }

// let socket = new WebSocket(
// "wss://javascript.info/article/websocket/demo/hello"
// );

// socket.onopen = function (e) {
// console.log("З*єднання встановленно");
// socket.send("Привіт");
// socket.send("Я Христя");
// };

// socket.onmessage = function (e) {
// console.log("message", e.data);
// };

// socket.onclose = function (event) {
// if (event.wasClean) {
// console.log("Зупинено", event.code);
// } else {
// console.log("Poзірвано");
// }
// };

// socket.onerror = function (err) {
// console.log(err);
// };
let socket = new WebSocket(
"wss://javascript.info/article/websocket/demo/hello"
);

socket.onopen = function (e) {
console.log("З*єднання встановленно");
socket.send("Привіт");
socket.send("Я Христя");
};

socket.onmessage = function (e) {
console.log("message", e.data);
};

socket.onclose = function (event) {
if (event.wasClean) {
console.log("Зупинено", event.code);
} else {
console.log("Poзірвано");
}
};

socket.onerror = function (err) {
console.log(err);
};
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "lesson13",
"version": "1.0.0",
"description": "TCP/IP HTTP/ HTTPS CRUD REST API Fetch async/await try...catch",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/legogoUA/Lesson13.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/legogoUA/Lesson13/issues"
},
"homepage": "https://github.com/legogoUA/Lesson13#readme"
}