Using #Electron to call a .NET #API
Electron is a platform that allows you develop desktop applications which are cross-platform, and run on standard HTML , CSS , Javascript and Node. The mix of typically client-and-“server side” javascript is very unusual, but quite liberating.
Here is a simple example of using Electron with an API that typically would be called by server-side Node, in a desktop app here –
https://github.com/infiniteloopltd/ElectronRegCheck
It’s not really that much beyond the “hello world” example, but shows the basics of using a simple user interface, and calling an API.
The code in “renderer.js” is as follows;
var api = require(‘car-registration-api-uk’);
window.$ = window.jQuery = require(‘jquery’);$(init);
function init()
{
$(“#btnSearch”).bind(“click”,btnSearch_click);
}function btnSearch_click()
{
var reg = $(“#reg”).val();
api.CheckCarRegistrationUK(reg,”*** your username here***”,function(data){
$(“#output”).html(data.Description);
});
}
You’ll need an account on RegCheck.org.uk for this to work.