Ravenous Part 4 -I can only search for businesses in the USA in my app

so after finishing my ravenous- 4 and everything was ok and amazing I hit the search business button and I get back results if I give a location in the usa uk but Evrytime I give a Location in my country Kenya Im getting a typeError of unHandled rejection and map of undefined.

Hello, Yelp itself doesn’t support all countries so it doesn’t always have results to give. The steps provided for the project don’t include specific steps for handling of this scenario, so you didn’t miss anything.

If Yelp returns an error or no results, then the state of businesses ends up getting set to undefined in App.js. App.js then sends this undefined state to the BusinessList component, which then attempts to use map() on it since it is supposed to be an array.

You could prevent this from happening different ways. One way would be in Yelp.js by returning an empty array if there are no listings found. Another way would be in the searchYelp() function in App.js by checking the value before using setState

1 Like

woow okay thanks thanks alot for the help.