I have a problem: when I pass two types of objects as an argument to a remote method, the first argument is overwritten by the second argument. Below is the code and results. How can I say that the second argument does 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 the main argument {"name": "Tom"} and the secondary argument {"name:" Joe "} after the console registers the JSON objects primary and secondary, I get the result.
primary { "name": "Joe" <--- WHY?! } secondary { "name: "Joe" }
As you can see, Tom has been rewritten by Joe.
source share