I’m new to this so please be patient. I’m creating a node,js app in WebStorm and have hit a bit of a problem. I have created a js called sparkfuncs.js which holds all the login code and functions to retrieve values. This works great server side, but I’d also like to call some if the higher level functions from the browser.
The reason for writing the sparkfuncs.js file was to centralise all spark related functions and also hide the access tokens and device Ids from the user. For example I’m not happy with the web page java script:
requestURL = “https://api.spark.io/v1/devices/” + deviceID + “/” + getFunc + “/?access_token=” + accessToken
As this publishes the data to the user that I want to hide. The problem I’ve come across in my script is the require statement eg:
var spark = require(‘spark’);
I’ve done some reading around this and it’s a server side function which is not supported by the browser. I’ve taken a look at a script called requirejs but can’t get my head around it.
Thanks for reading…