{"ScriptPreparationCode":"function showResult(data) {\r\n //console.log(data);\r\n}\r\nvar newUrl = \u0022https://www.googleapis.com/discovery/v1/apis\u0022;","TestCases":[{"Name":"Native XHR","Code":"try {\r\n var xhr = new XMLHttpRequest();\r\n xhr.open(\u0022GET\u0022, newUrl, true);\r\n xhr.onreadystatechange = function() {\r\n if (xhr.readyState === 4) {\r\n showResult(xhr);\r\n }\r\n }\r\n xhr.send();\r\n} catch (error) {\r\n console.log(error);\r\n} finally {\r\n // done\r\n}","IsDeferred":false},{"Name":"Native XHR (try/catch)","Code":"var xhr = new XMLHttpRequest();\r\nxhr.open(\u0022GET\u0022, newUrl, true);\r\nxhr.onreadystatechange = function() {\r\n if (xhr.readyState === 4) {\r\n showResult(xhr);\r\n }\r\n}\r\nxhr.send();","IsDeferred":false},{"Name":"Fetch (promise)","Code":"var request = fetch(newUrl).then(showResult);","IsDeferred":false},{"Name":"Fetch (async/await)","Code":"var testThis = async function() {\r\n var response = await fetch(newUrl);\r\n var data = await response.json();\r\n return data;\r\n}\r\ntestThis().then(function(data){\r\n showResult(data);\r\n});","IsDeferred":false},{"Name":"Fetch (async/await - try/catch)","Code":"var testThis = async function() {\r\n try {\r\n var response = await fetch(newUrl);\r\n var data = await response.json();\r\n } catch (error) {\r\n console.log(error);\r\n } finally {\r\n return data;\r\n }\r\n}\r\ntestThis().then(function(data){\r\n showResult(data);\r\n});","IsDeferred":false}]}