John John - 10 months ago 61
MySQL Question

How to grab the computer name with NodeJs / Electron?

I am trying to retrieve the computer name from my computer so I can use it in comparison in my mysql query. Below is the query:

connection.query("SELECT box_id, longestDimension from box where longestDimension != '' AND box_id = computerName", function(err, rows, fields) {

I would like to define
as a variable that grabs the user-defined computer name using
. This application is being run via electron for windows.

Any help would be greatly defined

Answer Source

You can use the standard nodeJS os API to retrieve the (host)name of a computer, see this API documentation for more details.

computername = os.hostname()