ZoneMinder API NodeJS Project Help?
Posted: Tue Oct 15, 2019 7:39 pm
Hopefully there is a javaScript developer out there to help out, but I have been attempting to toggle my cameras "mode" between Modect and Mocord.
This project is running in NodeJS, I have successfully been able to change the camera's mode while using postman, however when I try to make the same POST request in NodeJS the new mode doesn't set. I am using "request" to simplify the request. Documentation on that is here: https://github.com/request/request#forms
Here's some code:
Here's the response from zoneminder:
However, whenever I check zoneminder's console, I do not see that any of the modes have changed on any of the cameras.
This project is running in NodeJS, I have successfully been able to change the camera's mode while using postman, however when I try to make the same POST request in NodeJS the new mode doesn't set. I am using "request" to simplify the request. Documentation on that is here: https://github.com/request/request#forms
Here's some code:
Code: Select all
request.post({
url: `${zmRoot}/monitors/${camera}.json`,
form: {
Monitor: {
Function: mode, //This holds a string value of either "Modect" or "Mocord."
}
}
}, (err, httpResponse, body) => {
if (err) {
reject(err);
} else {
resolve(JSON.parse(body));
}
});
Code: Select all
{ message: 'Saved' }