में परिणाम मेरे पास एक उल्का विधि है जो http.get के आसपास लपेटती है। मैं उस http.get से परिणामों को वापस लौटने की कोशिश कर रहा हूं ताकि जब मैं विधि को कॉल करता हूं तो मैं परिणामों का उपयोग कर सकता हूं।
हालांकि मैं इसे काम नहीं कर सकता।वापसी मेटीर। परिणाम
(में साझा किए गए फ़ोल्डर)
Meteor.methods({
getWeather: function(zip) {
console.log('getting weather');
var credentials = {
client_id: "string",
client_secret: "otherstring"
}
var zipcode = zip;
var weatherUrl = "http://api.aerisapi.com/places/postalcodes/" + zipcode + "?client_id=" + credentials.client_id + "&client_secret=" + credentials.client_secret;
weather = Meteor.http.get(weatherUrl, function (error, result) {
if(error) {
console.log('http get FAILED!');
}
else {
console.log('http get SUCCES');
if (result.statusCode === 200) {
console.log('Status code = 200!');
console.log(result.content);
return result.content;
}
}
});
return weather;
}
});
किसी कारण के लिए, यह परिणाम वापस नहीं करता है, भले ही वे मौजूद हैं और http कॉल काम करता है:: console.log
यहाँ मेरी कोड है (result.content); वास्तव में परिणाम लॉग इन करता है।
(क्लाइंट फ़ोल्डर)
Meteor.call('getWeather', somezipcode, function(error, results) {
if (error)
return alert(error.reason);
Session.set('weatherResults', results);
});
पाठ्यक्रम यहाँ के
, सत्र चर खाली किया जा रहा समाप्त होता है।
(ध्यान दें कि कोड के इस हिस्से ठीक होने के लिए के रूप में यह उचित रूप से वापस आ अगर मैं कठिन विधि में कुछ डमी तार के साथ वापसी कोडित लगता है।)
मदद?
यह मेरे लिए धन्यवाद, धन्यवाद। – oliv23
यह ग्राहक पर कैसे प्राप्त किया जा सकता है? – janjackson