correctly return if arguments are missing

This commit is contained in:
Daniel Sommer 2022-03-25 16:44:22 +01:00
parent 2739ebed2a
commit a55c7a9929

View file

@ -13,10 +13,10 @@ async function getServiceState(name) {
} }
async function setServiceState(name, args) { async function setServiceState(name, args) {
if (name === undefined || args === undefined) { if (name === undefined) {
return; return;
} }
let state = args.get('state'); let state = args?.get('state');
if (state === undefined) { if (state === undefined) {
const msg = 'missing argument \'state\', pass either \'active\', \'inactive\' or \'toggle\''; const msg = 'missing argument \'state\', pass either \'active\', \'inactive\' or \'toggle\'';
logger.debug(msg); logger.debug(msg);