diff --git a/02_advanced/unterricht/tag13/01_pyramid-of-doom.html b/02_advanced/unterricht/tag13/01_pyramid-of-doom.html new file mode 100644 index 0000000..6d41ddc --- /dev/null +++ b/02_advanced/unterricht/tag13/01_pyramid-of-doom.html @@ -0,0 +1,92 @@ + + + + + + The Pyramid Of The Doom - callback hell - Beispiel + + + + + +
+
+

The Pyramid Of The Doom - callback hell - Beispiel

+ + +
+
1
+
2
+
3
+
4
+
+
+
+ + + diff --git a/02_advanced/unterricht/tag13/02_promise-aufbau.html b/02_advanced/unterricht/tag13/02_promise-aufbau.html new file mode 100644 index 0000000..801d578 --- /dev/null +++ b/02_advanced/unterricht/tag13/02_promise-aufbau.html @@ -0,0 +1,59 @@ + + + + + + Promise Object - Syntax + + + +
+
+

Promise Object - Syntax

+

+ Das + Promise + Objekt stellt eine Repräsentation einer eventuellen Ausführung (oder eines Fehlschlags) einer + asynchronen + Operation und den daraus resultierenden Ergebnissen dar. +

+ +
+
+ + + diff --git a/02_advanced/unterricht/tag13/03_node-hello.js b/02_advanced/unterricht/tag13/03_node-hello.js new file mode 100644 index 0000000..a420803 --- /dev/null +++ b/02_advanced/unterricht/tag13/03_node-hello.js @@ -0,0 +1 @@ +console.log('Hello World!'); diff --git a/02_advanced/unterricht/tag13/04_node-fs-promise.js b/02_advanced/unterricht/tag13/04_node-fs-promise.js new file mode 100644 index 0000000..04c3295 --- /dev/null +++ b/02_advanced/unterricht/tag13/04_node-fs-promise.js @@ -0,0 +1,25 @@ +const fs = require('fs'); // Modul au der Standardlibrary von Node +// require - commonjs Schreibweise + +const getFile = (path = '') => { + return new Promise((resolve, reject) => { + // asynchrones auslesen einer Datei + fs.readFile(path, 'utf-8', (error, data) => { + if (error) { + // console.error(error); + reject(error); + } + + // console.log(data); + resolve(data); + }); + }); +}; + +console.log('weiter im code....'); +// more logic... + +// Funktionsaufruf einer Funktion, die asynchrone Prozesse beinhaltet +getFile('02_promise-aufbau.html') + .then((data) => console.log(data)) + .catch((err) => console.error(err));