1
Im混合聚合物一點點,我試圖創建一個簡單的獲取請求來檢索我的Github信息。我正在檢索錯誤Polymer.httpRequest is not a function
。當明確是。不是函數錯誤,聚合物
Polymer({
is: 'custom-element',
properties: {
name: ''
},
httpRequest: function(type, url){
var getRequest = new XMLHttpRequest();
var data = getRequest.responseText;
getRequest.open(type, url, true);
getRequest.send();
console.log(data);
return data;
}
});
Polymer.httpRequest('GET', 'https://api.github.com/users/joshspears3');
任何想法爲什麼它會返回此錯誤?我在這裏先向您的幫助表示感謝。
你擺脫聚合物錯誤後,您不能從異步方法返回。並且您在進行Ajax調用之前正在讀取responseText。 – epascarello
你不要用Polymer來調用這個方法。你用它引用的元素調用它。 – epascarello