I have an issue where when I pass two object types as a remote method argument, the first argument gets overwritten by the second argument. Below is code and results. How could I go about not having the second argument not overwrite the first argument?
module.exports = (Model) => {
Model.calculate = (primary, secondary) => {
console.log(JSON.stringify(primary, null, 2));
console.log(JSON.stringify(secondary, null, 2));
return new Promise((resolve, reject) => {
resolve({ Model: calculator.calculate() });
});
};
Model.remoteMethod('calculate', {
accepts: [
{ arg: 'primary', type: 'object', http: { source: 'body' } },
{ arg: 'secondary', type: 'object', http: { source: 'body' } }
],
returns: {arg: 'Result', type: 'string'}
});
};
When I pass in the primary argument { "name": "Tom" } and secondary argument { "name: "Joe" } after console logging the JSON objects primary and secondary I get the result.
primary
{
"name": "Joe" <--- WHY?!
}
secondary
{
"name: "Joe"
}
As you can see Tom was overwritten to Joe.