Object 环回:在远程方法中传递多个对象类型

Object 环回:在远程方法中传递多个对象类型,object,arguments,loopbackjs,overwrite,strongloop,Object,Arguments,Loopbackjs,Overwrite,Strongloop,我有一个问题,当我将两个对象类型作为远程方法参数传递时,第一个参数会被第二个参数覆盖。下面是代码和结果。我怎样才能不让第二个参数覆盖第一个参数呢 module.exports = (Model) => { Model.calculate = (primary, secondary) => { console.log(JSON.stringify(primary, null, 2)); console.log(JSON.stringify(secondary, n

我有一个问题,当我将两个对象类型作为远程方法参数传递时,第一个参数会被第二个参数覆盖。下面是代码和结果。我怎样才能不让第二个参数覆盖第一个参数呢

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'}
  });
};
当我传入主参数时 { “姓名”:“汤姆” }第二个论点 { 名字:“乔” } 在控制台记录JSON对象主对象和次对象之后,我得到了结果

primary 
{
  "name": "Joe" <--- WHY?!
}

secondary 
{
  "name: "Joe"
}
primary
{
“姓名”:“乔”更改:

Model.remoteMethod('calculate', {
    accepts: [
      { arg: 'primary', type: 'object', http: { source: 'body' } },
      { arg: 'secondary', type: 'object', http: { source: 'body' } }
    ],
    returns: {arg: 'Result', type: 'string'}
  });
致:

http:{source:'body'}
将整个html正文作为对象值发送,因此您将发送两次,这看起来像是一个名为
name
的表单字段,但如果不是这样,请提供更多的代码


但需要注意的是,它是可选的:-)

谢谢!它成功了!:)
Model.remoteMethod('calculate', {
    accepts: [
      { arg: 'primary', type: 'object' },
      { arg: 'secondary', type: 'object' }
    ],
    returns: {arg: 'Result', type: 'string'}
  });