axios is one of the most downloaded HTTP clients for JavaScript. This small function is why a 404 lands in your catch block: after every response it decides whether the request's promise succeeds or fails.
What to look for
The whole rule is one question: no status, no validateStatus setting, or a status that validateStatus accepts means success.
How much Thunder could read
3 of 4 steps put into words; the other 1 is shown as code.
Read by the current Thunder compiler when this page was built. Hand-checked against the code: accurate and useful: every sentence checked against the code is true.
››››
Flow: How does it go? One action or rule as a path: questions with Yes and No, repeats, the Stops, what happens if something goes wrong, and what always happens at the end.
In this file
Settle
From codelines 14–26
Author's noteResolve or reject a Promise based on response status.
The same reading as Thunder Text, built with this page
Settle
Author's note: Resolve or reject a Promise based on response status.
You give it: resolve, reject, response
- `const validateStatus = response.config.validateStatus;` (code, not explained) (line 15)
- Ask: The response's status is not set or validate status is not set or validate status(the response's status)? (line 16)
Yes:
- Calls resolve (with response) (line 17)
No:
- Calls reject (line 19)
Copyright (c) 2014-present Matt Zabriskie & Collaborators. Licensed under the MIT. The code is shown unmodified; the Thunder reading is ThunderLang's.
Full license text (LICENSE)
# Copyright (c) 2014-present Matt Zabriskie & Collaborators
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.