I\'m using fetch polyfill to retrieve a JSON or text from a URL, I want to know how can I check if the response is a JSON object or is it only text
fetch(UR
Use a JSON parser like JSON.parse:
function IsJsonString(str) { try { var obj = JSON.parse(str); // More strict checking // if (obj && typeof obj === "object") { // return true; // } } catch (e) { return false; } return true; }