#Axios post not working

1 messages · Page 1 of 1 (latest)

real marshBOT
#

Hi @sand girder. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Based on the knowledge sources provided, there could be several reasons why you're encountering a network error when making a POST request with Axios in a client component. Here are a few potential issues and solutions:

  1. Axios Version: There was an issue reported with Axios version 1.6.8 causing problems with Next.js. Downgrading to version 1.6.7 seemed to resolve the issue for some users (source (https://github.com/vercel/next.js/issues/63084)).

  2. Server Environment: Axios might not be able to find a suitable adapter to dispatch the request in your server environment. This could be due to the environment not supporting the xhr adapter or the http adapter not being available in the build (source (https://github.com/vercel/next.js/issues/62800)).

  3. Fetch API: If you're also using the Fetch API, there could be a conflict. One user reported a TypeError: Failed to parse URL error when using Fetch. If this is the case, you might want to consider using only one method for making HTTP requests (source (https://github.com/vercel/next.js/issues/62800)).

  4. Server Response: The server might not be sending a response, or the response might not be in the expected format. This could cause Axios to throw a network error. Make sure your server is set up to handle POST requests and is sending a response in the correct format.

If none of these solutions work, you might want to consider using Next.js's built-in fetch() function instead of Axios for making HTTP requests. This could potentially resolve any compatibility issues between Axios and Next.js.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: