Debugging and Fixing Common JavaScript Errors

Challenge 3: Server Reporting 400 Bad Request Errors

Debugging and Fixing Common JavaScript Errors

Check out a free preview of the full Debugging and Fixing Common JavaScript Errors course

The "Challenge 3: Server Reporting 400 Bad Request Errors" Lesson is part of the full, Debugging and Fixing Common JavaScript Errors course featured in this preview video. Here's what you'd learn in this lesson:

In this challenge, students identify and resolve a user-form validation bug.

Preview
Close

Transcript from the "Challenge 3: Server Reporting 400 Bad Request Errors" Lesson

[00:00:00]
>> Here's a bug that our monitoring actually caught. And our monitoring is saying that, a lot of our requests back to the server, are coming back with a 400 or a 400 bad request, as the HTTP code says. In fact this happened 200 times, we've posted to /api/rants/, and we've gotten this 400.

[00:00:21]
And our server people, they're not so happy with that, they don't want us making these bad calls. And we don't wanna waste a bunch of network bandwidth and transition time, making calls that aren't gonna succeed. So, let's see if we can understand why these 400 bad requests are happening.

[00:00:38]
The other thing that we can tell from our monitoring, is that, we have some context about the timeline that's happened, based on the monitoring tools that we're using. And I know that before this Ajax happens, there's two important events that are always happening. First, the user inputs zero characters into that text area, and then they click on a button.

[00:01:00]
And those two events are always happening right before that 400. So let's see if we can recreate that with our own development environment. So I'm just gonna give this a reload, make sure we're in a clean environment. So I'm going to enter zero characters into our text area, so I'm not gonna do anything.

[00:01:23]
And I'm going to click on the submit button. And the Chrome Console, nicely even reports that to me, it shows me, hey, there was a post to this URL www.getrantr.com port 9000/api/rants I'm gonna leave it to you, to take the next step after that, and figure out, why is that happening and what can we do about it?

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now