Home > Uncategorized > Using #Electron to call a .NET #API

Using #Electron to call a .NET #API

Screenshot 2019-06-02 at 15.04.30

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.

Advertisement
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: