Uniface User Forum

 View Only
  • 1.  Javascript API POST/GET

    Posted 07-26-2021 21:51

    Hello I am doing an internship and I am writing a Javascript Create, Read, Update, Delete application in which I would like to use Uniface's javascript API.


    Right now I am using the Axios API which has a method .post() to post something through the API.


    The same works for GET


    Now I am wondering if the Uniface Javascript API has some similar methods to this, and if not, what would be the best way to make POST/GET requests through the Uniface Javascript API?


    Thanks,

    Jurjen



  • 2.  RE: Javascript API POST/GET

    ROCKETEER
    Posted 07-27-2021 08:39

    Hi Jurjen,

    Using the Uniface JavaScript API you don't need to directly perform HTTP GET/POST requests from/to a URL in a REST style - you can just use the uniface API's activate() method to directly invoke Uniface operations with parameters (they will be asynchronous, so you may want to use JavaScript promises to wait for a result .then do something).

    In this kind of interface, I often find it useful to convert JavaScript objects to JSON and back with standard JavaScript commands, e.g. JSON.stringify() and JSON.parse(), and use Uniface's struct commands (e.g. structToJSON, jsonToStruct, structToComponent, and componentToStruct to convert data on the server).

    If you want to use a REST approach (e.g. continuing to use the Javascript Axios API) that is also possible, but it's a different topic - in summary you would need to create a Uniface REST component to provide an interface.

    Regards,

    David