Error connecting to the network: apisauce

Encountered a NETWORK_ERROR while attempting to fetch data from my Django server.

CORS headers are functioning correctly on the backend.

I have tried using localhost and my machine's IP address, but it still does not work.

Here is the result of console.log(response.originalError):

Network Error at node_modules/apisauce/node_modules/axios/lib/core/createError.js:15:17 in createError at node_modules/apisauce/node_modules/axios/lib/adapters/xhr.js:96:22 in handleError at node_modules/react-native/Libraries/Network/XMLHttpRequest.js:609:10 in setReadyState at node_modules/react-native/Libraries/Network/XMLHttpRequest.js:396:6 in __didCompleteResponse at node_modules/react-native/Libraries/vendor/emitter/_EventEmitter.js:135:10 in EventEmitter#emit

Answer №1

After successfully solving the issue, I managed to run my Django backend using my machine's IP address and it worked perfectly. I added the IP address to the setting.py file under ALLOWED_HOSTS = ['192.168.0.236'].

To run the backend server, simply use the command python manage.py runserver [your machine ip]:8000

  1. Start the backend server with your machine IP by running python manage.py runserver [your machine ip]:8000

Step 2 involves adding the machine IP to the setting.py file as well: ALLOWED_HOSTS = ['your machine IP']

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using the React JS useState hook to toggle the state of a JSON object containing an array when a checkbox is clicked

When I submit my state as a stringified variable from a form to a POST request via a lamda server, it gets parsed and sent to sendgrid for templating. To loop over specific parts (multiple checkboxes) in JSON format, each with the same key but different va ...

What is required to run npm rebuild node-sass --force following each instance of a `yarn add` command?

As I attempt to set up the isemail npm library, everything appears to be going smoothly. However, when I execute yarn start:dev, which essentially runs "npm run build:dev && ./scripts/gendevconfig.sh && cross-env BABEL_DISABLE_CACHE=1 NODE_ ...

Using ASP.NET Server Controls to Toggle Textbox Visibility Based on Dropdown Selection

What is the optimal method for displaying or hiding a textbox or an entire div section based on a user's selection from a dropdown menu? I am uncertain if this can be achieved with server controls, so would it require using standard client-side HTML c ...

Executing tasks sequentially with the help of django, celery, and redis

My setup involves using django, celery, and redis to launch tasks asynchronously. # tasks.py @shared_task def my_task(): # Code here for task 1 return True # Located in test1.py my_task.delay() # A few milliseconds later in test2.py my_task.de ...

refresh PHP automatically using JavaScript

Working on my Laravel application, there is a JavaScript function that I have defined: function abc(){ var x = '<?php ($user && ($user->first_name == "" || $user->number == "")) ?>'; } Upon initial page load, the variable ...

Generate a dynamic add to cart section for every last configurable choice, assisting with this task

Currently, I am involved in a project that involves displaying configurable options on a product page, along with querying the database to check which vendors carry the product. The list of vendors is then displayed using JavaScript. In order to make the ...

When selecting an input within a div, the Angular onblur function is behaving erratically

How can I prevent the div from closing when I click on an input inside it after setting a tabindex to the div and closing it on blur? Solution for app.component.html: <button (click)="openToggle('toggle1')">Toggle 1</button> ...

Upload Request Failure Due to Drag and Drop Functionality in HTML5

Recently, I implemented a drag and drop upload form on a webpage. The 'normal' file input functioned perfectly as expected when prompting for a file to be selected. However, I encountered an issue where the POST request was missing the file infor ...

Tips for successfully passing multiple data IDs in a Bootstrap modal

Greetings! I am currently facing a challenge with passing multiple data IDs into a bootstrap modal. When I manually assign the data IDs, everything works perfectly: <a id="testB" href="#my_modal2" data-toggle="modal" data-book-id='{"id":10,"name ...

Iterate over a collection of objects to find connections between the starting and ending points, and retrieve the number of occurrences

My challenge involves analyzing an array of objects containing origin and destination data, and the total volume of objects moving between locations. I am specifically looking to compare flow counts between two cities. For example, when the origin is Vanco ...

The IE browser consistently retrieves outdated data from its cache

I always encounter the issue of IE browser loading old data from the browser history. To ensure that I am getting the latest data, I consistently need to clear the browser history. Is there a way to consistently load new data without having to manually cl ...

Challenges with asynchronous problems related to importing models utilizing promises in conjunction with the three.js

I'm currently struggling to resolve a promise in my script. The promise needs to be resolved when a function containing 3D file imports finishes importing, but I'm unsure how to make this happen. Is there a way to receive a signal or data from t ...

Is there a way to make an input field mandatory in Gravity Forms by utilizing javascript or jquery?

I am currently in the process of developing a registration form for an upcoming event using gravity forms. The objective is to allow users to register only if the number of participants matches the number of available shirts. In case they do not match, the ...

Error encountered: MongoDB failed to execute Javascript as it was unable to save a DBQuery object in the specified location within the collection.js file

When attempting to modify an existing document in a MongoDb collection, an exception is generated with the following message: javascript execution failed : can't save a DBQuery object at src/mongo/shell/collection.js The following actions are perform ...

TS: How can we determine the type of the returned object based on the argument property?

Assume we have the following data types type ALL = 'AA' | 'BB' | 'CC'; type AA = { a: number; }; type BB = { b: string; }; type CC = { c: boolean; }; type MyArg = { type: ALL }; I attempted to create a mapping between type n ...

Tips for storing an array of strings in a JSON file using Javascript

Is it possible to save an array of strings to a JSON file using Node.js? const alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']; example.json [ "a", "b&q ...

How can you use JavaScript to identify resize or zoom changes across all ancestor DOM elements?

I have a DOM element that consists of a chart. <div id="plot1" class='plot-chart'></div> This specific DIV can be nested within various other DIVs. <div id="one" style="width:100%;height:100%;zoom:0.9;"> <div id="two"& ...

Issue with pagination and filtering in Smart-table.js

Presently, my focus is on developing functionality for Smart-table.js, which requires the following features: Retrieve JSON data from a web service Create a table with pagination and filtering capabilities Implement filters for individual columns or globa ...

Aggregate the values in an array and organize them into an object based on their frequency

I have an array of information structured like this: 0: { first: "sea", second: "deniz", languageId: "English-Turkish"} 1: { first: "play", second: "oynamak", languageId: "English-Turkish&qu ...

Receive a response in fragments from express on the browser

As I work on creating a progress bar to track long-running server-side tasks that may take up to a few minutes, I am exploring different methods to display the progress of each task. While WebSockets and interval polling are options, I prefer using long-po ...