這是我從終端獲取我的錯誤我收到服務器異常錯誤終端 - 流星
Exception while invoking method 'getCustomerNameByAppIdReactive' { stack: 'TypeError: Cannot read property \'customerId\' of undefined
at [object Object].getCustomerNameByAppIdReactive (server/Functions/searchFunctions.js:167:20)
at [object Object].methodMap.(anonymous function) (packages/meteorhacks_kadira/lib/hijack/wrap_session.js:164:1)
at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1711:12)
at packages/ddp-server/livedata_server.js:711:19
at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
at packages/ddp-server/livedata_server.js:709:40
at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
at packages/ddp-server/livedata_server.js:707:46
at tryCallTwo (/home/saran/.meteor/packages/promise/.0.7.3.3xbt0b++os+web.browser+web.cordova/npm/node_modules/promise/lib/core.js:45:5)
at doResolve (/home/saran/.meteor/packages/promise/.0.7.3.3xbt0b++os+web.browser+web.cordova/npm/node_modules/promise/lib/core.js:200:13)', I20170824-11:47:30.445(5.5)? source: 'method' }
這是流星方法我寫在服務器
getCustomerNameByAppIdReactive: function(appointmentId){
let customerId = Appointments.findOne({
_id: appointmentId}).customerId;
if (customerId == 「1」){
return 「Walk-In Customer」;
} else {
return Customers.findOne({_id:customerId}).name;
}
},
這是來自客戶端的無效方法調用
getCustomerName: (appointmentId)=>{
return ReactiveMethod.call(「getCustomerNameByAppIdReactive」,appointmentId);
},
此方法工作得很好,但在終端出現錯誤
"Exception while invoking method ‘getCustomerNameByAppIdReactive’ { stack: 'TypeError: Cannot read property ‘customerId’ of undefined\n at [object Object].getCustomerNameByAppIdReactive (server/Functions/searchFunctions.js:167:20)\n at [object Object].methodMap.(anonymous function) "
任何人,如果你有這個問題?
我加入上面的代碼,但得到的ReferenceError:在調用方法的customerId沒有定義「異常‘getCustomerNameByAppIdReactive’{堆棧:「的ReferenceError:在[對象的對象] .getCustomerNameByAppIdReactive(服務器/功能沒有被定義的customerId \ N/searchFunctions.js:185:36)\ n「 – vishnusaran
我在」return Customer.findOne({_ id:appt 。.customerId})名稱;」之後,沒有錯誤感謝兄弟的幫助 – vishnusaran