This commit is contained in:
Philippe Torrel
2026-07-02 13:11:49 +02:00
parent 253411f3c9
commit f0dd230fe9
8 changed files with 91 additions and 6 deletions

View File

@@ -47,7 +47,7 @@
},
);
// Empfholene Schreibweise - then nur für "Erfolg" (resolve) - catch für "Fehler" (reject)
// Empfohlene Schreibweise - then nur für "Erfolg" (resolve) - catch für "Fehler" (reject)
promise
.then((result) => {
console.log('OK: ', result);

View File

@@ -12,7 +12,7 @@
}
.menu-main {
background-color: steelblue;
background-color: tomato;
}
.menu-main ul {
list-style: none;

View File

@@ -21,7 +21,7 @@
// Menu Main
.menu-main {
background-color: steelblue;
background-color: tomato;
ul {
list-style: none;
display: flex;

View File

@@ -0,0 +1,4 @@
name, category, price
Klingon Letter Opener, Office Warfare, 19.99
Backpack of Holding, Travel, 29.99
Tardis Alarmclock, Merchandise, 15.99
1 name category price
2 Klingon Letter Opener Office Warfare 19.99
3 Backpack of Holding Travel 29.99
4 Tardis Alarmclock Merchandise 15.99

View File

@@ -0,0 +1,28 @@
// fs = FileSystem Modul aus der Node Standardbib
const fs = require('fs'); // commonjs - Node Schreibweise
// Funktion mir einem asynchronen Prozess
const getContentBy = (path) => {
return new Promise((resolve, reject) => {
// asynchroner Prozess
fs.readFile(path, 'utf-8', (err, data) => {
if (err) {
// console.error(err);
reject(err);
}
// console.log(data);
resolve(data);
});
});
};
// Funktionsaufruf einer Funktion mit asynchronem Prozess
getContentBy('data/productss.csv')
.then((data) => {
console.log(data);
})
.catch((err) => {
console.error(err);
});
console.log('weiter im code...');

View File

@@ -0,0 +1,13 @@
{
"name": "01_promise-and-readfile",
"version": "1.0.0",
"description": "",
"license": "ISC",
"author": "",
"type": "commonjs",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": []
}