question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Axios Post Works but Responds with Network Error

See original GitHub issue

I 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);
	}
}

axios_error

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:closed
  • Created 5 years ago
  • Comments:39 (1 by maintainers)

github_iconTop GitHub Comments

30reactions
ibovangeffencommented, Jun 24, 2019

Having the same issue. Postman does work, axios doesn’t

5reactions
jasonsaaymancommented, Jun 24, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found