たれぱんのびぼーろく

わたしの備忘録、生物学とプログラミングが多いかも

Fetch API周りの丁寧な世界

URLSearchParams

fetch Bodyにセットすると自動でContent-Typeをapplication/x-www-form-urlencoded;charset=UTF-8にしてくれる、安全。

To safely extract a body and a Content-Type value from object, run these steps:
... Set Content-Type to application/x-www-form-urlencoded;charset=UTF-8.
Fetch Living Standard

query parameterを使いたい(not JSON)のならばこのオブジェクト.
ToString()で文字列を吐けるので、POST BodyじゃなくてGET URL querystringにも利用できる.