Closed Runi-VN closed 4 years ago
Must change URL back to proper one before merge
also need to fix this sh!tshow. pls give async/await
Initial thoughts:
Finish this as soon as possible and implement editPerson using the following:
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
subsection Uploading JSON data
For this assignment, considering we cannot use async/await, it might not that much of an issue to:
a) save fetchData in a variable
b) create multiple fetches
c) Grabbing data right off the DOM
d) I forgot
I like option a because I need a full json body for editPerson
@Castau and I agreed to bring this up during the final project meeting.
For this assignment, considering we cannot use async/await, it might not that much of an issue to: a) save fetchData in a variable b) create multiple fetches c) Grabbing data right off the DOM d) I forgot
Option a) and c) are not possible, I think. The writing of data to the DOM or a variable will happen at some time after the the code has run past the first fetching of data, so the data you "read in" in your next fetch will not exist yet. It's the exact same problem I had when i made the dropdown-data and the functions that use that data.
You can do fetch-in-fetch or callbacks from the first fetch, as I have understood. If you want the data presented to the user and then resubmitted (where the user has to pres a new button) I think you can get around this, since the user will have to have time to read, process and pres a button.
So a option e) might be:
Ready to merge. Did not manager to prettify output, had a few attempts with bootstrap grid/flex, but it didnt work and its late.
GeneratePerson()
could have been smarter made (lots of repeat code) but I'm out of time.
for
-loop instead of a for...in
-loop, as I could have used the index for a few operations.
Fixes #7 Fixes #44
Changes in this PR
deletePerson
-method properly shows some errors, but not all. These are instead logged. Hmm.handleHttpErrors
to always output errors on the webpage, but it's hard to take use of theResponse
-object, as it is locked to the current use???Current errors
The
addUpdateButtons
does not run 100% correctly.If your first attempt to look up a person is correct ("FirstName LastName") it will display buttons as it should.
If you somehow messes up, then correct it, it will take not one, but two clicks on
Get User
to trigger the function.Shown in GIF:
I believe the
addUpdateButtons
-function finishes before thesingleuser
-function is done, on which it is reliant.