24 lines
733 B
JavaScript
24 lines
733 B
JavaScript
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);
|
|
});
|
|
}
|
|
|