Error 413 does not contain status code
See original GitHub issue#### Summary
In the follow code snippet,
axios.post('/api/files/new', formData, config)
.then(response => this.fileUploaded(response.data, name, size))
.catch(e => {
console.log('error uploading file:')
console.warn(e.response)
})
if the api rejects with 413 (“file too large”), e.response is undefined. Multiple reasons can lead to a nul response, and we need to be able to distinguish. In this case, at the reject phase, that status is lost.
At the same time, servers should not have to attach response bodies for all forms of malformed requests.
#### Context
- axios version: 0.15.3
- Environment: vueJS/node custom project
Issue Analytics
- State:
- Created 6 years ago
- Reactions:8
- Comments:7
Top Results From Across the Web
How to Solve the "413 Request Entity Too Large" Error - Kinsta
In a nutshell, the “413 Request Entity Too Large” error is a size issue. It happens when a client makes a request that's...
Read more >Getting HTTP Error 413 Request entity too large when ... - Poly
The 413 status code indicates that the request was larger than the server can handle, either due to physical constraints or settings. Why...
Read more >PageRequestManagerServerErr...
The 413 status code indicates that the request was larger than the server is able to handle, either due to physical constraints or...
Read more >Fixing 413 Request Entity Too Large Errors - KeyCDN Support
Fixing this error is about increasing the maximum file size for the server in question. Once that is done, the error should no...
Read more >413 HTTP Response Status Code Definition - Holistic SEO
The 413 HTTP Status Code indicates that the server is refusing to process a request because the request payload is too large for...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey all, I took a few minutes to troubleshoot this issue. Here are some things I found:
error.response
populated. This is because the XHR request fails at the browser level (during theOPTIONS
call), which is technically a network error. For network errors, axios does not provide a response because one is not provided by the browser. If one debugs the network error returned to axios from an invalidOPTIONS
call, one will notice that there is no way to know the status.I think the reason is
validateStatus
. See my notes. And feel free to remind me if it is not solved.