Node.jsでXMLHttpRequestを使う
Node.jsでXMLHttpRequestを使おうとしたら以下のエラーがでて怒られた。
ReferenceError: XMLHttpRequest is not defined
XMLHttpRequestは、Webブラウザーの組み込みオブジェクトで、Node.jsには含まれていないみたい
つらい
Node.jsで使いたければ個別にインストールが必要
なので
① yarn(or npm) で install
yarn add xmlhttprequest
②コードでimport して使う
import { XMLHttpRequest } from 'xmlhttprequest'
終わり