From the course: JavaScript: Ajax and Fetch

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Work with authorization errors

Work with authorization errors - JavaScript Tutorial

From the course: JavaScript: Ajax and Fetch

Start my 1-month free trial

Work with authorization errors

- [Instructor] When errors happen in an API request, sometimes half the battle is understanding what went wrong. Often the error code and message returned from a failed request is enough to point you in the right direction. But once you have a general idea of the issue, it's also important to understand how to fix it. One common error you might encounter is an Authorization Error. Which corresponds with a 401 HTTP code. When you request results in this error, it generally has to do with your API key. A few things can go wrong with an API key. The first place to check is to ensure that the key in your code matches the credential issued by the web service. A copy and paste error or even erroneously typing or deleting a single character in the wrong place can cause issues here. If the key and your code matches the provided string, another thing to check is that you're using the correct key. Some providers such as SmartyStreets provide multiple authentication strings and it's up to you to…

Contents