So far I could save my queries into the database with post-request.
let database = [
{'email': 'h@v.d', 'name': 'Vu', 'vorname': 'Hai'},
{'email': 'm@h.d', 'name': 'Heim', 'vorname': 'Manuel'},
{'email': 'h@v.d', 'name': 'Heinrich', 'vorname': 'Leon'},
];
server.post('/MyWebApp/mydatabase', function(req, res){
let p_mail = req.body.email;
let p_name = req.body.name;
let p_nachname = req.body.nachname;
console.log(database);
database.push({'email': p_mail, 'name': p_name, 'nachname': p_nachname});
console.log(database);
});
I can enter name, surname and e-mail and save them.
<script>
function save() {
let in_email = document.getElementById("mail").value;
let in_name = document.getElementById("name").value;
let in_nachname = document.getElementById("nachname").value;
$.post('http://localhost:2019/MyWebApp/mydatabase',
{ 'email': in_email, 'name': in_name, 'nachname': in_nachname },
function (data) {
console.log('Object: ' + data);
}
);
}
</script>
<table>
<tr>
<td>E-Mail:</td>
<td><input type="text" size="80" id="mail" /></td>
</tr>
<tr>
<td>Vorname:</td>
<td><input type="text" size="80" id="name" /></td> <
</tr>
<tr>
<td>Nachname:</td>
<td><input type="text" size="80" id="nachname" /></td>
</tr>
<tr>
<td><input type="button" value="Ausgeben" onClick="get();" /></td>
<td><input type="button" value="Speichern" onClick="save();" /></td>
</tr>
</table>
So my question is now: If I put the e-mail in the email field and click on "send" I should get the name and surname for that e-mail.
I have no idea how to do it...