2017-07-28 45 views

回答

0

要調用一個異步功能,這就是爲什麼

console.log("myresult-->",myresult) //myresult is undefined here 

立即叫Meteor.http.call執行後,無論是否已接收到結果還是不行。

既然你是在服務器端,但是,您可以方便地調用HTTP的同步版本:

import { HTTP } from 'meteor/http' 

const myresult = HTTP.call("POST", "/abcd/efd", {data:payload}); 
console.log("myresult-->" my result) //myresult is defined here 

更多閱讀上:https://docs.meteor.com/api/http.html#HTTP-call

相關問題