let headers = new Headers();
headers.set("Content-Type", "application/json");
headers.set("Authorization", "Basic " + btoa("<username>" + ":" + "<pwd>"));
let inits = {
headers: headers,
mode: "no-cors"
};
let request = new Request("https://twcservice.eu-gb.mybluemix.net/api/weather/v1/geocode/"+lat.toFixed(2)+"/"+lng.toFixed(2)+"/forecast/daily/3day.json?language=en-US&units=m", inits);
fetch(request)
.then((response) => {
console.log(response);
return response.json();
})
.then((json) => {
for(let i = 0; i <= 3; i++) {
console.log(json['forecasts'][i]['dow']+" - "+json['forecasts'][i]['narrative']);
}
});
我可能做错了什么,但没有从浏览器收到任何错误消息。
Response { type: "opaque", url: "", redirected: false, status: 0, ok: false, statusText: "", headers: Headers, body: null, bodyUsed: false }
怎么了?