# React Native Part 2 (Networking: Fetching Data)

**URL:** <https://forum.codewithmosh.com/t/react-native-part-2-networking-fetching-data/1250>\
**Category:** React Native\
**Created:** [December 13, 2020, 6:01am UTC](https://forum.codewithmosh.com/t/react-native-part-2-networking-fetching-data/1250 "2020-12-13T06:01:33Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![aarongraham](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@aarongraham](https://forum.codewithmosh.com/u/aarongraham)\
**Post date:** [December 13, 2020, 6:01am UTC](https://forum.codewithmosh.com/t/react-native-part-2-networking-fetching-data/1250/1 "2020-12-13T06:01:33Z")

</div>

“NETWORK\_ERROR” problem! Application and Node backend both running ☹ Please assist!! !

 ![Capture2](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/1X/38220fb4a5b574ee5341b68f3a5a00452472b4c4.png)

---

<div class="post-metadata">

**Author:** ![aarongraham](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@aarongraham](https://forum.codewithmosh.com/u/aarongraham)\
**Post date:** [December 13, 2020, 6:07am UTC](https://forum.codewithmosh.com/t/react-native-part-2-networking-fetching-data/1250/2 "2020-12-13T06:07:33Z")

</div>

Additional capture

 ![Capture1](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/1X/076116bc8c9c3207e4893c72c1af5749e524b122.png)

---

<div class="post-metadata">

**Author:** ![aarongraham](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@aarongraham](https://forum.codewithmosh.com/u/aarongraham)\
**Post date:** [December 13, 2020, 6:10am UTC](https://forum.codewithmosh.com/t/react-native-part-2-networking-fetching-data/1250/3 "2020-12-13T06:10:24Z")

</div>

development.json  
{  
“assetsBaseUrl”: “[http://192.168.0.1:9000/assets/](http://192.168.0.1:9000/assets/)”,  
“port”: 9000  
}

listings.js:  
import client from ‘./client’;

const endpoint = ‘/listings’;

const getListings = () =\> client.get(endpoint);

export default {  
getListings,  
}

client.js:  
import {create} from ‘apisauce’;

const apiClient = create({  
baseURL: ‘[http://192.168.0.1:9000/api/listings](http://192.168.0.1:9000/api/listings)’  
});

export default apiClient;

---

<div class="post-metadata">

**Author:** ![jon\_h\_chan](https://avatars.discourse-cdn.com/v4/letter/j/4491bb/32.png) [@jon\_h\_chan](https://forum.codewithmosh.com/u/jon_h_chan)\
**Post date:** [December 14, 2020, 5:06am UTC](https://forum.codewithmosh.com/t/react-native-part-2-networking-fetching-data/1250/4 "2020-12-14T05:06:26Z")

</div>

I know mosh said it would not work but for me I set the baseUrl in client.js and the assetsBaseUrl in the back end project’s development.json file to local host (“[http://localhost:9000/api](http://localhost:9000/api)”) and it worked for me.

---

<div class="post-metadata">

**Author:** ![aarongraham](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@aarongraham](https://forum.codewithmosh.com/u/aarongraham)\
**Post date:** [December 16, 2020, 2:00pm UTC](https://forum.codewithmosh.com/t/react-native-part-2-networking-fetching-data/1250/5 "2020-12-16T14:00:49Z")

</div>

I will try this and keep you posted :)! thx

---

<div class="post-metadata">

**Author:** ![aarongraham](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@aarongraham](https://forum.codewithmosh.com/u/aarongraham)\
**Post date:** [December 16, 2020, 4:07pm UTC](https://forum.codewithmosh.com/t/react-native-part-2-networking-fetching-data/1250/6 "2020-12-16T16:07:04Z")

</div>

no luck :(. Can you post your development.json, listings.js and listingsScreen.js?

Thanks. This is crazy ☹

---

<div class="post-metadata">

**Author:** ![wcroteau](https://avatars.discourse-cdn.com/v4/letter/w/e36b37/32.png) [@wcroteau](https://forum.codewithmosh.com/u/wcroteau)\
**Post date:** [December 17, 2020, 2:04pm UTC](https://forum.codewithmosh.com/t/react-native-part-2-networking-fetching-data/1250/7 "2020-12-17T14:04:31Z")

</div>

Some random thoughts to investigate that may help you out:

Double-check your IP - I know that setups vary wildly however your posted IP sounds suspiciously like the IP for the gateway…

Can you connect to the backend using Postman?

---

<div class="post-metadata">

**Author:** ![aarongraham](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@aarongraham](https://forum.codewithmosh.com/u/aarongraham)\
**Post date:** [December 17, 2020, 4:52pm UTC](https://forum.codewithmosh.com/t/react-native-part-2-networking-fetching-data/1250/8 "2020-12-17T16:52:17Z")

</div>

In the name of Larry David, “BINGO!!!”

wrong ip ☹

Thanks! 😉

---

<div class="post-metadata">

**Author:** ![Ellie](https://avatars.discourse-cdn.com/v4/letter/e/bc8723/32.png) [@Ellie](https://forum.codewithmosh.com/u/Ellie)\
**Post date:** [December 27, 2020, 8:17pm UTC](https://forum.codewithmosh.com/t/react-native-part-2-networking-fetching-data/1250/9 "2020-12-27T20:17:35Z")

</div>

Hello,  
I have the same “Network Error” problem. I am using windows and Android emulator. My Api (C# .Net core) is running fine locally at [http://localhost:3000/odata/User](http://localhost:3000/odata/User) but I get “Network Error” when trying to access it from the emulator.  
Here is the code snippet:  
const apiClient = create({

baseURL: “[http://10.0.2.2:3000/odata](http://10.0.2.2:3000/odata)”,

});

const getUser = () =\> apiClient.get("/User");

any ideas why I get the error?

Thanks!

---

<div class="post-metadata">

**Author:** ![mosestosin35](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@mosestosin35](https://forum.codewithmosh.com/u/mosestosin35)\
**Post date:** [December 29, 2020, 1:39pm UTC](https://forum.codewithmosh.com/t/react-native-part-2-networking-fetching-data/1250/10 "2020-12-29T13:39:14Z")

</div>

Good days guys. I’m having the same problem as described above and I have tried possible solution but no result yet. why is this network error an issue because I did exactly what Mosh did?

---

<div class="post-metadata">

**Author:** ![aarongraham](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@aarongraham](https://forum.codewithmosh.com/u/aarongraham)\
**Post date:** [December 29, 2020, 4:46pm UTC](https://forum.codewithmosh.com/t/react-native-part-2-networking-fetching-data/1250/11 "2020-12-29T16:46:07Z")

</div>

have you checked your ip? Making sure it’s not the default gateway?

---

<div class="post-metadata">

**Author:** ![mosestosin35](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@mosestosin35](https://forum.codewithmosh.com/u/mosestosin35)\
**Post date:** [December 30, 2020, 12:15am UTC](https://forum.codewithmosh.com/t/react-native-part-2-networking-fetching-data/1250/12 "2020-12-30T00:15:32Z")

</div>

Please help confirm the ip address

 ![please help confirm this](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/1X/dda9858f79bd6b1138e418cc693c00760cb72899.png)

---

<div class="post-metadata">

**Author:** ![mosestosin35](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@mosestosin35](https://forum.codewithmosh.com/u/mosestosin35)\
**Post date:** [December 30, 2020, 12:17am UTC](https://forum.codewithmosh.com/t/react-native-part-2-networking-fetching-data/1250/13 "2020-12-30T00:17:51Z")

</div>

Please how did you confirm the ip to be wrong

---

<div class="post-metadata">

**Author:** ![aarongraham](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@aarongraham](https://forum.codewithmosh.com/u/aarongraham)\
**Post date:** [December 30, 2020, 12:46am UTC](https://forum.codewithmosh.com/t/react-native-part-2-networking-fetching-data/1250/14 "2020-12-30T00:46:06Z")

</div>

possibly run ipconfig on the command line and make sure you are not using the default gateway. maybe the ipv4 address.  
good luck!!!

---

<div class="post-metadata">

**Author:** ![Ellie](https://avatars.discourse-cdn.com/v4/letter/e/bc8723/32.png) [@Ellie](https://forum.codewithmosh.com/u/Ellie)\
**Post date:** [January 1, 2021, 6:52pm UTC](https://forum.codewithmosh.com/t/react-native-part-2-networking-fetching-data/1250/15 "2021-01-01T18:52:55Z")

</div>

Hi,  
I finally fixed the problem by using the ipv6 address. So my api address looks like this: http://[2600:8087:3500:cab6::e265]:5555/odata/user.  
Run ipconfig, find your ipv6 address and put it inside square brackets like: http://[your ipv6]:your port/your api

Hope this helps.

---

<div class="post-metadata">

**Author:** ![aarongraham](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@aarongraham](https://forum.codewithmosh.com/u/aarongraham)\
**Post date:** [January 1, 2021, 7:09pm UTC](https://forum.codewithmosh.com/t/react-native-part-2-networking-fetching-data/1250/16 "2021-01-01T19:09:59Z")

</div>

It helps everyone!!! Good luck with the rest of the project.

---

<div class="post-metadata">

**Author:** ![Ben](https://avatars.discourse-cdn.com/v4/letter/b/df788c/32.png) [@Ben](https://forum.codewithmosh.com/u/Ben)\
**Post date:** [January 10, 2021, 11:08pm UTC](https://forum.codewithmosh.com/t/react-native-part-2-networking-fetching-data/1250/17 "2021-01-10T23:08:41Z")

</div>

> [@aarongraham](#):
>
> you checked your ip? Making s

I used IPv4, v6, localhost … nothing, I the array is empty!

---

<div class="post-metadata">

**Author:** ![Ben](https://avatars.discourse-cdn.com/v4/letter/b/df788c/32.png) [@Ben](https://forum.codewithmosh.com/u/Ben)\
**Post date:** [January 12, 2021, 10:55pm UTC](https://forum.codewithmosh.com/t/react-native-part-2-networking-fetching-data/1250/18 "2021-01-12T22:55:01Z")

</div>

Could you help me please, It doesn’t work using all IPV4, 6 whatever!

---

<div class="post-metadata">

**Author:** ![aarongraham](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@aarongraham](https://forum.codewithmosh.com/u/aarongraham)\
**Post date:** [January 12, 2021, 11:18pm UTC](https://forum.codewithmosh.com/t/react-native-part-2-networking-fetching-data/1250/19 "2021-01-12T23:18:45Z")

</div>

I would first do this:

1. download his github project.
2. go to folder/topic you are on C:\Part 2\Section 3- Networking\End (this will depend on where you downloaded the course material)
3. run npm install in your directory which will download all of the npm dependencies
4. then check: your baseURL with your ip. (maybe run ipconfig to see the possible address) (everyone’s ip is different’ish 192.168.0.0 \<-who knows what your number will be

const apiClient = create({  
baseURL: “[http://192.168.0.14:9000/api](http://192.168.0.14:9000/api)”,  
});

Good luck 🙂

---

<div class="post-metadata">

**Author:** ![Ben](https://avatars.discourse-cdn.com/v4/letter/b/df788c/32.png) [@Ben](https://forum.codewithmosh.com/u/Ben)\
**Post date:** [January 14, 2021, 9:18pm UTC](https://forum.codewithmosh.com/t/react-native-part-2-networking-fetching-data/1250/20 "2021-01-14T21:18:41Z")

</div>

> [@aarongraham](#):
>
> run npm install in your directory which will download all of the npm dependencies

Hello Sir, Thank you for your try, of course, this is the last solution, I would understand why it didn’t work, by chance I found it last night !, it was something really ridiculous! I didn’t put () for the function loadListings in Listingscreen.js, now My screen still empty, the error is : [TypeError: undefined is not an object (evaluating ‘response.data’)]

 ![image](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/1X/b588d4e5736fa12443874476325f94f31a47fda0.png)

[Next page](https://forum.codewithmosh.com/t/react-native-part-2-networking-fetching-data/1250.md?page=2)
