test Ajax, fetch()

x
input url:
data/test.html
data/test.xml
data/test.json
https://learn.javascript.ru/article/fetch/logo-fetch.svg

https://romanlaptev-bookmarks.glitch.me/db/lib.json
https://romanlaptev-cors.herokuapp.com/https://romanlaptev.github.io/projects/bookmarks/db/lib.json
https://raw.githubusercontent.com/romanlaptev/bookmarks/master/db/lib.json

https://api.rasp.yandex.net/v3.0/search/?from=851508&to=851635&format=json&apikey=b07a64bc-f237-4e79-9efb-b951ec68eaf7&date=2019-11-26&transport_types=suburban&system=esr&show_systems=esr

----- read Google doc CSV
https://docs.google.com/spreadsheets/d/e/2PACX-1vSVjTcWRV0d7g3SBJSggJEGNp6rkTqIp91ME7UIluSLbPHFqV6LbuDQx3_vI2HI8Q/pub?gid=1862636504&single=true&output=csv

ajax-content

https://developer.mozilla.org/ru/docs/Web/API/Fetch_API
https://developer.mozilla.org/ru/docs/Web/API/Response
https://learn.javascript.ru/fetch
https://learn.javascript.ru/fetch-api

https://habr.com/ru/post/252941/
Введение в fetch

https://github.com/github/fetch
window.fetch polyfill
		
function sendForm(n) {
	let obj = Object.fromEntries(calculatorMap);

	fetch("/calculator/mail.php", {
		method: 'post',
		body: JSON.stringify({ items: obj, name: n.name.value, phone: n.phone.value, code: n.code.value }),
		headers: {
			'Content-Type': 'application/json'
		}
	}).then(function (response) {
		return response.text();
	}).then(function (text) {
		if (text === 'ok') {
			ym(51755942, 'reachGoal', 'calculator');
			alert('Спасибо! Ваша заявка получена, мы свяжемся с Вами в ближайшее время.');
			n.classList.remove('codesent');
			n.reset();

		} else {
			alert(text);
		}
	}).catch(function (error) {
		log('Request failed', error)
	});
}