So überprüfen Sie, ob die Antwort eines Abrufs ein json-Objekt in Javascript ist

Ich verwende fetch polyfill, um eine JSON oder einen Text von einer URL abzurufen. Ich möchte wissen, wie ich überprüfen kann, ob die Antwort ein JSON-Objekt oder nur Text ist.

fetch(URL, options).then(response => {
   // how to check if response has a body of type json?
   if (response.isJson()) return response.json();
});

Antworten auf die Frage(4)

Ihre Antwort auf die Frage