You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On the production client, it has been necessary to convert incoming data to JSON for handling inside the .write function. eg
Device.prototype.write = function (data) {
var self = this;
data = JSON.parse(data);
// I'm being actuated with data!
However, this generates an error on the new enterprise client, given that "data" is already an object.
My work around to make the driver valid on both platforms is:
Device.prototype.write = function (data) {
var self = this;
if (Object.prototype.toString.call(data) != "[object Object]") { data = JSON.parse(data); }
// I'm being actuated with data!
The text was updated successfully, but these errors were encountered:
My thinking was that the old way was wrong, and we'd just have to adjust the drivers, just how you'd suggested. That said, i could also catch the json parse exception and send in a string instead =)
I guess it is a matter of communicating that change?
At the moment, the error causes the driver to fail completely - so that's probably a poor user experience.
Catching the exception would probably be a good idea, but that may introduce a "lazy" response and result in drivers that rely on the exception being caught.
On the production client, it has been necessary to convert incoming data to JSON for handling inside the .write function. eg
Device.prototype.write = function (data) {
var self = this;
data = JSON.parse(data);
// I'm being actuated with data!
However, this generates an error on the new enterprise client, given that "data" is already an object.
My work around to make the driver valid on both platforms is:
Device.prototype.write = function (data) {
var self = this;
if (Object.prototype.toString.call(data) != "[object Object]") { data = JSON.parse(data); }
// I'm being actuated with data!
The text was updated successfully, but these errors were encountered: