5
我有其中當我傳遞兩個對象類型作爲遠程方法參數的問題傳遞多個對象類型,第一個參數得到由第二個參數覆蓋。以下是代碼和結果。我怎樣才能不讓第二個參數覆蓋第一個參數呢?迴環:在一個遠程方法
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"
}
,你可以看到湯姆被覆蓋到喬
謝謝!有效! :) – emarel