P.2, Networking, 4) Why I don't see the images

Hello everyone,
Everything seems to work fine, but the images are missing.

  1. Try to check your images directly in the browser. Go to api/listings using your IP and port number and check if it loads the images.

  2. Use react-native-debugger and see what returns to you from listing calls. My assumption is that there is something wrong with the network/simulator and you can’t access images fast enough…

  3. Try the code that Mosh gives at the beginning of each section, see if it works. If it does, find the differences?

Hope it helps

1 Like

Thx Denis,
I tried the first and the image doesnt display even it s really existing in the folder “server side”.
I tried to debug , nothing ! no error!

Last chance is to copy the code and test as you suggested.
regards,

Hello @denistepp (sorry for the delay)

ip:port/api/listings shows the JSON file with the links to the images.
But when I press on a link it keeps loading and never shows the image.
But what I found strange, is that the image url has the IP address of Mosh.
e.g. “url”: “http://192.168.0.14:9000/assets/jacket1_full.jpg”,`

So I replaced the IP address to mine and “voila” !!!

Are these urls hardcoded?
Is there something I can do, to download the assets with my IP in the images url?

Thanks

URLs are not hardcoded. Your backend runs on your IP address and takes the images from the address that you listed in client.js. If I am not mistaken you should only change the IP in one place (client.js) and all should work well. Don’t forget to run your backend server (node index.js)

Let me know if I got it correctly, I might have not understood your question right :frowning:

Yeah. copy the end stage code and change the ip to yours in client.js. See if it works. Let me know.

@denistepp
I’ve changed the IP in client.js so I do get to see the cards and everything else.
And I do run my back end server. Before that I couldn’t see anything.
What I think I need, is to get the JSON file with the urls of the images, with my IP instead that of Moshe’s
`
{
“id”: 201,
“title”: “Red jacket”,
“images”: [
{
“url”: “http://192.168.0.14:9000/assets/jacket1_full.jpg”,
“thumbnailUrl”: “http://192.168.0.14:9000/assets/jacket1_thumb.jpg”
}
],
“price”: 100,
“categoryId”: 5,
“userId”: 1,
“location”: {
“latitude”: 37.78825,
“longitude”: -122.4324
}http://192.168.0.14:9000/assets/jacket1_full.jpg
},

`
When I try to see the image on the browser with my IP address instead of 192.168.0.14, I see the image.
So I guess, if the JSON file had my IP address in the images urls, I would see the images.
Right?

On the server-side: change the address to your development.json
Regards

I have already…,
{ "assetsBaseUrl": "http://my-IP:9000/assets/", "port": 9000 }
otherwise I wouldn’t get the rest of the information. Right?

What bugs me though, is that I checked the RN debugger, where I see that it fails to load response data!

Could you please check if you retrieve the image on your browser?
http://your ip :9000/assets/jacket1_full.jpg

No worries guys, there was no bug.
I just remembered that every time you change something in the backend code, you need to restart the server.
I was getting Mosh’s IP address because, I started the server with his IP address!
Then I changed the IP, but didn’t restart the server.
Dum beginners fault, I guess.
Please forgive me for wasting your time.
I hope there was something to learn though…
Happy coding!!!

Happy coding :slight_smile:

I am wondering if there was a solution to this error, I am currently on this part, so I had to build the back end myself, but I am not able to get the images to load

content was outdate, which is the reason i had to rebuild the back end