おはようございます。
最近アレクサの天気予報が外れて痛い目をみたのでちょっとアレクサ予報を信じれなくなってきてますどうもハヤトワンです。
今日は大寒波(らしい)
ということで今日のjs
//fetchの微妙な点
url = "https://jsonplaceholder.typicode.com/posts1233456/"
fetch(url)
.then(response => console.log(response))
.catch(error => console.log('問題発生',error));
// GET https://jsonplaceholder.typicode.com/posts1233456/ 404
// Response {type: "cors", url: "https://jsonplaceholder.typicode.com/posts1233456/", redirected: false, status: 404, ok: false, …}
// body: (...)
// bodyUsed: false
// headers: Headers {}
// ok: false
// redirected: false
// status: 404
// statusText: ""
// type: "cors"
// url: "https://jsonplaceholder.typicode.com/posts1233456/"
// __proto__: Response
//404の結果は返ってくるが、問題発生のログが出ていない。ということはcatchが通っていない。
//他のajaxのライブラリ(jQuery ajax,Axiosなど)は異常なステータスコードが入ってきたらcatchにいくが
//nativeのfetchは問題が起きたときcatchにはいかない
//ステータスコードが404とか、サーバーがレスポンス返してる場合はthenを返すようになっている
//どういうときにcatchにはいるのか?
//ネットワークのリクエスト自体が失敗するとcatchにいく
//↓こんな感じ
url2 = "https://jsonplaceholder.typicode1233456.com/posts/"
fetch(url2)
.then(response => console.log(response))
.catch(error => console.log('問題発生',error));
// GET https://jsonplaceholder.typicode1233456.com/posts/ net::ERR_NAME_NOT_RESOLVED
// 問題発生 TypeError: Failed to fetch
今日の英語
There are gun marks on the wall:壁に銃の跡が残っている
country side:田舎
above:上に
the place is safe for the people to still stay:人々がまだ滞在するのに安全な場所
what is black sugar made of? :黒砂糖は何で出来てる?
going home:帰省
cuisine:料理
bullet train: 新幹線
ash:灰
Ashes fall in Kagoshima:鹿児島は灰が降ります
では今日も良い一日を!