Axios Post Works but Responds with Network Error
See original GitHub issueI searched for this here, around the internet and I went and signed up in the chat but no one’s there. No response in a day.
Summary
I’m learning so excuse my newb code. I’m using async functions with axios that all work except for one. This one did work before as I never saw this error come up when I implemented it. The updateItem(item)
method is the one giving an error. What’s weird is that I was using axios.put
no problem but was getting an invalid verb error. Switched to axios.post
and it does work, it hits the method and sends the item and when the method is finished an Ok(200) response is returned. But an error is thrown on the axios.post
call of a network error. I’ll show the code and error below.
async function deleteSelectedItemsAsync(removedItems) {
try {
let response = await axios.post('/Items/DeleteItems', removedItems);
console.log('Delete response: ' + response.status);
} catch (e) {
console.log(e);
}
}
async function updateItem(item) {
var response;
try {
item.editButtonMessage = "Edit";
response = await axios.post('/Items/UpdateItems', item);
} catch (e) {
console.log(response);
console.log(e);
}
}
async function addItemToDatabaseAsync(item) {
try {
const response = await axios.post('/Items/PostItem', item);
} catch (e) {
alert(e);
}
}
Context
- axios version: v0.18.0
- Environment: Windows 10, Edge 41.16299.666.0, Chrome Dev 71.0.3573.0 (Official Build) dev (64-bit), and Regular Chrome latest version
Issue Analytics
- State:
- Created 5 years ago
- Comments:39 (1 by maintainers)
Top Results From Across the Web
Post request Axios : Network error - node.js - Stack Overflow
I've a problem with request Axios network. All my Get request work. But Post request don't work. I have just this error "network...
Read more >Axios Network Error when making HTTP request [Solved]
The path has to be correct e.g. /articles . The HTTP method (e.g. GET or POST ) has to be correct for the...
Read more >How to Handle API Errors in Your Web App Using Axios
It can mean anything from “Your device doesn't have internet connectivity” to “Your OPTIONS returned a 5xx” (if you make CORS requests). The...
Read more >How to catch the body of an AXIOS error - Zelig880 -
This error can happen if we have made an actual mistake in setting up the AXIOS request. It could be something with the...
Read more >axios error 500 bad response - You.com | The AI Search ...
Assume you have requested some API with valid API credentials, but you do not have the ... axios/axiosAxios Post Works but Responds with...
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 FreeTop 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
Top GitHub Comments
Having the same issue. Postman does work, axios doesn’t
This sounds a lot like a mixture of errors. I doubt the error lies within Axios though from what I have read. If someone can give an example where it is shown to be a definitive Axios issue please open a new ticket for that issue.