Hi there, all I wanted was something like:
Session.set('currentSoundGroup', Meteor.call('get_twin_data', sasString, deviceID));
But thats of course too simple for a client/server situation. So, after searching this forum, stack overflow and elsewhere I am more confused.
On my server I have:
Meteor.methods({
'get_twin_data': function (SaS, DeviceID) {
if (Meteor.isServer) {
return registry.getModuleTwin(DeviceID, moduleId)
.then((res) => {
console.log('Promise resolved', res.responseBody.deviceId);
return res;
}).catch((e) => {
console.log('Promise failed', e);
throw new Meteor.Error(500, 'There was an error processing your request');
});
}
And on the client I have:
GetSoundGroupTwin = (sasString, deviceID) => {
return new Promise((success, failure) => {
Meteor.call('get_twin_data', sasString, deviceID, (error, soundGroup) => {
if (error) {
console.log("Inside error of promise handler");
failure(error)
}
else {
console.log("Inside success of promise handler");
console.log(soundGroup);
success(soundGroup)
}
});
});
};
async handleTwinClick(device) {
console.log("handleClick for Twin");
Session.set('currentSoundGroup', 'Looking...');
const sasString = this.props.device.sas_string;
const deviceID = this.props.device.device_id;
this.GetSoundGroupTwin(sasString, deviceID)
.then((result) => {
console.log('Twin Fetched: ', result);
}).catch((e) => {
console.log('Error: ', error.reason);
})
}
First of all, the client code never returns, and no value is passed back.
And secondly, the server states “unhandledRejection Maximum call stack size exceeded”
So, wrapping up, is my approach right, and where is the core problem?