我試圖使用their api從「darksky.net」獲取信息。來自darksky.net的訪問控制 - 允許來源錯誤請求數據
var xhr = new XMLHttpRequest();
xhr.open(method, url, true);
xhr.onload = function() {
if (this.status >= 200 && this.status < 300) {
resolve(xhr.response);
} else {
reject({
status: this.status,
statusText: xhr.statusText
});
}
};
請回答只有在純JavaScript。