reworked DTC-Data handling

This commit is contained in:
2023-09-27 19:13:54 +02:00
parent d593e40f38
commit 2138f640ee
27 changed files with 397 additions and 149 deletions

View File

@@ -0,0 +1,23 @@
const jsonFilePath = "static/dtc_table.json";
function getDescriptionForDTCNumber(number, callback) {
fetch(jsonFilePath)
.then((response) => response.json())
.then((data) => {
const foundEntry = data.find((entry) => entry.num === number);
if (foundEntry) {
const description = foundEntry.description;
const title = foundEntry.title;
callback(null, title, description);
} else {
// Wenn die Nummer nicht gefunden wurde, geben Sie einen Fehler zurück
callback(`Beschreibung für Nummer ${number} nicht gefunden.`,null, null);
}
})
.catch((error) => {
// Im Fehlerfall geben Sie den Fehler zurück
callback(error, null, null);
});
}