Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Creating A Promise With JSON

/*directly writing new Response(data) does NOT work if data is a JSON, for JSON you need a blob*/
	 var data = {key: "value"};
		 var blob = new Blob([JSON.stringify(data, null, 2)]);
		 var myResponse = new Response(blob);
	 	console.log(await myResponse.json());
 
PREVIOUS NEXT
Tagged: #Creating #A #Promise #With #JSON
ADD COMMENT
Topic
Name
1+7 =