function requestHandler(request, response) {
try {
if (“switch” in request.query) {
// ‘switch’ is a URL-encoded parameter, ie. '?switch=1’
local state = request.query.switch;
if (state == "on" || state = "1") state = 1;
if (state == "off" || state = "0") state = 0;
// Use the 'response' object to acknowledge reception of the request
// to the request's source. '200' is HTTP status code for 'OK'
response.send(200, "Setting received and applied");
// Send the command to the device
device.send("change.switch.state", state);
} else {
response.send(200, "Unknown command");
}
} catch (error) {
// Something went wrong; inform the source of the request
// '500' is HTTP status code for 'Internal Server Error'
response.send(500, error);
}
}
// Register the handler function as a callback
http.onrequest(requestHandler);
server.log(“Agent running”);
its say that i got error at (local state = request.query.switch;)…can anyone help me please