我想從服務器端返回一個值到客戶端,如果我從API調用中收到錯誤響應。在Meteor獲取400響應時無法返回值HTTP.post()
if Meteor.isClient
Meteor.call 'foo',data,(err,results)->
console.log(results)
if Meteor.isServer
Meteor.methods foo:(data)->
results = Meteor HTTP.post "example.com",{
data: data
},(err,results)
if err
console.log('abc')
return 0
如果我得到400錯誤來自example.com,然後在打印abc
但它不返回任何東西給客戶端。
由於提前,
你的語法是無效的,想必你的意思是把' - >'後''HTTP.post's(ERR,結果)',然後縮進接下來的三條線。 – user3374348