Skip to content

Conversation

@amythetester
Copy link

@amythetester amythetester commented Jun 3, 2019

TREK

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
What does it mean for code to be asynchronous? This means that code can be run out of order compared to the order it was written. Usually this occurs because the program is waiting for some type of user input or network requests to execute the code.
Describe a piece of your code that executes asynchronously. How did this affect the way you structured it? My Document.ready is an area where my code executes asynchronously. This made it so I could put all of my functions near the top of the JS file and have certain functions wait until a click occurred.
What kind of errors might the API give you? How did you choose to handle them? One that I got a lot during this project was the 500 internal server error, others include 4xx errors. For the most part I put custom error messages so that the user could correct their behavior and continue to use the program.
Suppose you needed to routinely find a specific Trip in the list by it's ID field. Would it be advantageous to keep the list in order by the id field? Explain why or why not. I would not have to keep the trips in order by ID field because I could parse the HTML or even store that data in an object that I can access to find the ID. Having them in order would help the average user of the site find a trip by ID, but it would still take a lot of trial and error due to ID numbers not always starting at 1.

@CheezItMan
Copy link

TREK

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene Reasonable number of commits and good commit messages
Comprehension questions Check
Functionality
Click a button to load and view a list of trips Check
Clicking the "load" button twice does not cause each trip to display twice Check, button is removed so... great.
Click a trip to load and view trip details Check
Clicking a different trip loads different details Check
Submitting the form only sends one POST request Error See my inline comment, but the form can get multiple event handlers attached. Before adding a submit event handler you should clear all events.
Errors are reported to the user Check
Site is clearly laid out and easy to navigate Check
Under the Hood
Callback functions are not nested more than 2 levels deep Check
Callback functions are given descriptive names Check
Code is generally well-organized and easy to read Check
All API calls have both success and error callbacks defined Check, well done
HTML is semantic Check
CSS is DRY, uses CSS Grid, Flexbox, and/or Bootstrap It looks fine, good use of grid
Overall See my notes on your errors. Not bad, just some errors on event handling here.

}
});
};
$('#reservation-form').submit(createReservation);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every time you click on trips, this attaches a new event handler to the form. This means if I click on a few trips a few times and then fill out and submit the form, several submit event handlers will fire and I'll get added to the trip multiple times.

Take a look at it in dev tools with the network tab open. You'll see the problem.

Instead you should clear all the event handlers from the form before attaching a new one.

})
.catch((error) => {
console.log(error.response);
if (error.response.data && error.response.data.errors) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants