Comments (8)
You will find all this information in the error
property, or am I missing something?
const [{ error }] = useAxios(...)
from axios-hooks.
Strange, it's not giving me an object, it's giving me this instead:
Error: Network Error
at createError (createError.js:16)
at XMLHttpRequest.handleError (xhr.js:81)
Going to try and reproduce it in codesandbox, I'll update this comment afterwards.
from axios-hooks.
okay sure. that object though is what's returned by axios, see
Line 129 in 8706e4c
from axios-hooks.
I coudn't reproduce my problem, but I noticed that it's something that is documented in axios.
At least I know where the problem lies. Basically the error occurred on the request, so error.response
is obviously still undefined
. I could identify this by checking all the values mentioned in axios' docs.
error.response --> undefined
error.request --> XMLHttpRequest {klIsCORSRequest: true, readyState: 4, timeout: 0, withCredentials: false, onreadystatechange: ƒ, …}
error.message --> Network Error
error.config --> {url: "https://nonexistingurl.com", method: "get", headers: {…}, transformRequest: Array(1), transformResponse: Array(1), …}
from axios-hooks.
Correct, though unusual, HTTP errors may occur on the request rather than in the response (i.e. there's no network connectivity so the request cannot even leave the local network). In those cases, you will never have a response and in Axios that's communicated by an undefined response on the error object.
from axios-hooks.
@simoneb I think this is more like react issue, but anyway.
I had almost the same problem -- I request a wrong URL, which does not exist, then axios literally died and my NextJS server also died.
logs:
client/node_modules/axios/lib/core/createError.js:16
var error = new Error(message);
^
Error: Request failed with status code 404 at createError (client/node_modules/axios/lib/core/createError.js:16:15)
// really long (2200) config, request, response object info
error Command failed with exit code 1.
I don't think this is normal behavior. Axios dosen't return error, just die with react.
from axios-hooks.
This is a bug in your code. Neither axios or react simply "die".
from axios-hooks.
@simoneb Thank you for reply. It was actually ssr issue. when I set option {ssr: false}
that problem was gone.
I think nextJS or some of my unconscious setup make axios do a job at server-side.
from axios-hooks.
Related Issues (20)
- Release pending!
- Refetch "expression is not callable" HOT 2
- Why I'm getting 2 rendered using this hook, when component mounts? HOT 9
- Release pending!
- Prevent CanceledError and redundant HTTP calls for identical request data HOT 1
- Support for API polling HOT 1
- type error HOT 9
- Uncaught TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator)) HOT 1
- How to configure SSR with NextJS? HOT 3
- "Uncaught runtime errors: Cannot read properties of undefined (reading 'data')" after upgrading to CRA 5.0.1 & Node 18 HOT 6
- Not usable within the US? HOT 1
- Error from a dynamically loaded uri HOT 3
- Release pending!
- Release pending!
- useAxios hook sending in 2 requests, the first is cancelled immediately HOT 3
- Release pending! HOT 3
- Release pending!
- Release pending!
- Type error: MouseEvent using refetch and provided example from docs HOT 2
- Still an issue with both `executeGet` and `execute` methods when executed manually HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from axios-hooks.