I don't suppose someone could explain how you would go about setting up the http request? - I'm new to programming and z-way
I would use the HTTP request app in z-way, but I need to add an authentication header.
Basically I want to POST to:
https://api.lifx.com/v1/lights/SELECTOR/toggle
with the header:
"Authorization: Bearer TOKENID"
I did get this to work using xmlhttp in a browser console and thought I could just port that into the Javascript Code app in z-way, but that fails as I believe the xmlhttp object (maybe I said that wrong) is not available. I believe that object is built into my browser, which is why that works.
I tried to install xmlhttp via npm, but that didn't help.
I then tried the following code, but it doesn't work:
var options = {
url: 'api.lifx.com/v1/lights/SELECTOR/toggle,
port: 443,
method: 'POST',
headers: {
'Authorization': 'Bearer TOKENID'
}
};
http.request(options);
Any suggestions?