# Failed getting data from API React Native Project

**URL:** <https://forum.codewithmosh.com/t/failed-getting-data-from-api-react-native-project/11508>\
**Category:** React Native\
**Created:** [March 26, 2022, 2:19pm UTC](https://forum.codewithmosh.com/t/failed-getting-data-from-api-react-native-project/11508 "2022-03-26T14:19:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![KohXinHao](https://avatars.discourse-cdn.com/v4/letter/k/41988e/32.png) [@KohXinHao](https://forum.codewithmosh.com/u/KohXinHao)\
**Post date:** [March 26, 2022, 2:19pm UTC](https://forum.codewithmosh.com/t/failed-getting-data-from-api-react-native-project/11508/1 "2022-03-26T14:19:28Z")

</div>

I am trying to follow Mosh lesson to fetch data from API using apisuace.

But it keep return me null value when i try to print using console.log(response.data) after api call.

```auto
const [listings, setListings] = useState([]);

  useEffect(() => {

    loadListings();

  }, []);

  const loadListings = async () => {

    const response = await listingsApi.getListings();

    console.log(response.data);

    setListings(response.data);

  };

```

Here is my client.js file.

```auto
import { create } from "apisauce";

const apiClient = create({

  baseURL: "http://127.0.0.1:9000/api",

});

export default apiClient;

```

I also tried to access the following url from my web browser the data is showing.

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

``Is anyone know what is the problem? Thanks a lot!.

---

<div class="post-metadata">

**Author:** ![KishSoni](https://avatars.discourse-cdn.com/v4/letter/k/c57346/32.png) [@KishSoni](https://forum.codewithmosh.com/u/KishSoni)\
**Post date:** [August 26, 2022, 4:06pm UTC](https://forum.codewithmosh.com/t/failed-getting-data-from-api-react-native-project/11508/2 "2022-08-26T16:06:13Z")

</div>

I am facing the same issue. Did you managed to get the solution?

---

<div class="post-metadata">

**Author:** ![AlmTalal](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@AlmTalal](https://forum.codewithmosh.com/u/AlmTalal)\
**Post date:** [September 14, 2022, 5:36pm UTC](https://forum.codewithmosh.com/t/failed-getting-data-from-api-react-native-project/11508/3 "2022-09-14T17:36:49Z")

</div>

did you solve the problem, Im passing null data when loading the listings?

---

<div class="post-metadata">

**Author:** ![luisdiego](https://avatars.discourse-cdn.com/v4/letter/l/ac8455/32.png) [@luisdiego](https://forum.codewithmosh.com/u/luisdiego)\
**Post date:** [June 17, 2024, 5:07pm UTC](https://forum.codewithmosh.com/t/failed-getting-data-from-api-react-native-project/11508/4 "2024-06-17T17:07:14Z")

</div>

I did have the same issue: here is the solution

import { create } from “apisauce”;

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

export default apiClient;

backend:

{  
“assetsBaseUrl”: “[http://localhost:9000/assets/](http://localhost:9000/assets/)”,  
“port”: 9000  
}
