async function getPersonalDataById(id) {
	const response = await fetch('/api/' + id);
	return await response.json();
}

async function showPersonalDataById(target, id) {
	const data=await getPersonalDataById(id);

	let html = `<tr><th>id</th>
	<td>${data.row.id}</td><tr>
	<tr><th>name</th>
	<td>${data.row.name}</td><tr>
	<tr><th>email</th>
	<td>${data.row.email}</td><tr>
	</tr>`;
	target.innerHTML=html;
}

async function addPersonalData(data) {
	const response = await fetch('/api/add', {

		method: 'POST',
		headers: {
			'Content-Type': 'application/json'
		},
		body: JSON.stringify(data)
	});
	return await response.json();
}


async function updatePersonalData(data) {
	const response = await fetch('/api/edit', {
		method: 'POST',
		headers: {
			'Content-Type': 'application/json'
		},
		body: JSON.stringify(data)
	});
	return await response.json();
}

async function deletePersonalData(data) {
	const response = await fetch('/api/delete', {
		method: 'POST',
		headers: {
			'Content-Type': 'application/json'
		},
		body: JSON.stringify(data)
	});
	return await response.json();
}