Giter VIP home page Giter VIP logo

Comments (5)

TheNoim avatar TheNoim commented on August 14, 2024

Hallo, natürlich kann ich das machen. Was nutzt du? NodeJS? Oder ganz normal im Browser ?
LG

from dsbapi.

 avatar commented on August 14, 2024

Ich nutze eigentlich einen ganz normalen Webserver... brauche ich Node.js ?
Oder was genau meist du ? :)

from dsbapi.

TheNoim avatar TheNoim commented on August 14, 2024

Nein. Aber ich habe die Library darauf ausgelegt. Ich kann Morgen Abend eine Browser Version pushen und dann ein Beispiel angeben wie du es nutzen kannst. :)

from dsbapi.

 avatar commented on August 14, 2024

Ok danke das wäre nett ^^

from dsbapi.

TheNoim avatar TheNoim commented on August 14, 2024

Ich habe jetzt eine Browser Version commited. Sie befindet sich im Browser Ordner.
Um sie nun zu nutzen, musst du nicht viel tuen.

var dsb = new DSBLib("username", "password");
// Ich weiß nicht ob du weißt wie Promises funktionieren, also erkläre ich es mit und ohne.
// Du hast zwei Möglichkeiten. Einmal die alte API zu nutzen, oder die neue.
// Die neue hat den Nachteil, dass den JSON den du zurück bekommst etwas wirr ist, aber weil das die selbe ist, die auch die Offizielle Seite (http://mobile.dsbcontrol.de/) nutzt, denke ich, wird die am längsten verfügbar sein.
// Die alte hat den Vorteil sie ist sehr einfach zu verstehen, aber es könnte sein das sie in Zukunft obsolet wird. 

// Die alte (mit Promise):
dsb.getDataV1().then(function(Data) {
    console.log(Data);
}).catch(console.error);
// Mit callback
dsb.getDataV1(function(error, Data) {
    if (!error) {
        console.log(Data);
    } else {
        console.error(error);
    }
});
// Die neue (mit Promise)
dsb.getData().then(function(Data) {
    console.log(Data);
}).catch(console.error);
// Mit callback
dsb.getData(function(error, Data) {
    if (!error) {
        console.log(Data);
    } else {
        console.error(error);
    }
});

Ich habe die Browser Version jetzt nicht getestet, aber so sollte es gehen. Ich weiß auch nicht so wirklich wieso man es Client Seitig nutzen sollte. Ich habe es eher als Server Library ausgelegt.

from dsbapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.