Skip to content
Snippets Groups Projects
Commit 9ced3aff authored by Ruginosu, M.I. (Ioana, Student B-BIT)'s avatar Ruginosu, M.I. (Ioana, Student B-BIT) :ear_tone1:
Browse files

issue 2 the correct version

parent 095e5981
Branches issue#1
No related tags found
No related merge requests found
......@@ -62,18 +62,3 @@ function createPokemonTypesTable() {
`
}
function createTrainer() {
const name = document.getElementById('trainerName').value;
const profileurl = document.getElementById('profileUrl').value;
const data = {
profileUrl: profileurl,
name: name
}
fetch('/pokemon/api/trainers', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
}).then(response => updateTrainerTable())
}
\ No newline at end of file
......@@ -60,4 +60,33 @@ function createPokemonTypesTable() {
</tbody>
</table>
`
}
function createTrainer() {
const name = document.getElementById('trainerName').value;
const profileurl = document.getElementById('profileUrl').value;
const data = {
profileUrl: profileurl,
name: name
}
fetch('/pokemon/api/trainers', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
}).then(response => updateTrainerTable())
}
function updateTrainerTable() {
fetch('/pokemon/api/trainers')
.then(res => res.json())
.then(data => {
pokemonTypes = data;
createTrainerTable();
})
.catch(err => {
console.error(`Unable to fetch Pokemon Types: ${err.status}`);
console.error(err);
});
}
\ No newline at end of file
......@@ -14,7 +14,7 @@
</head>
<body>
<script src="js/requests.js"></script>
<script src="js/trainers.js"></script>
<script>
tableParentId = "tableDiv";
detailsParentId = "detailsDiv";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment