how get return the json data from the fetch in javascript code example

Example 1: javascript fetch json

fetch('./yourjson.json')
  .then((response) => response.json())
  .then((data) => {
  	console.log(data);
  })

Example 2: get data from fetch response html

fetch('/about').then(function (response) {
	// The API call was successful!
	return response.text();
}).then(function (html) {

	// Convert the HTML string into a document object
	var parser = new DOMParser();
	var doc = parser.parseFromString(html, 'text/html');

	// Get the image file
	var img = doc.querySelector('img');
	console.log(img);

}).catch(function (err) {
	// There was an error
	console.warn('Something went wrong.', err);
});