My Place Filtering Does Not Work

So I am working on a react application that uses the map and the API to fetch different places but can’t seem to get the filter method to work in the hook.

I get the error Unhandled Rejection (TypeError): Cannot read properties of undefined (reading ‘filter’) (anonymous function)

What should I do to fix it?

//type, coordinates, bounds change
useEffect(() => {
    if (bounds) {
      setIsLoading(true);

      getWeatherData(coords.lat, coords.lng)
        .then((data) => setWeatherData(data));

      getPlacesData(type, bounds.sw, bounds.ne)
        .then((data) => {
          setPlaces(data.filter((place) => place.name && place.num_reviews > 0)); //error here
          setFilteredPlaces([]);
          setRating('');
          setIsLoading(false);
        });
    }
  }, [bounds, type]);


export const getPlacesData = async (type, sw, ne) => {
    try {
        const { data : {data} } = await axios.get(`https://travel-advisor.p.rapidapi.com/${type}/list-in-boundary`, {
        params: {
            bl_latitude: sw.lat,
            tr_latitude: ne.lng,
            bl_longitude: sw.lng,
            tr_longitude: ne.lat,
          },
          headers: {
            'x-rapidapi-host': 'travel-advisor.p.rapidapi.com',
            'x-rapidapi-key': process.env.REACT_APP_RAPID_API_TRAVEL_API_KEY,
          }
        });
        console.log(`My Api response is ${data}`);
        return data;
    } catch (error) {
        console.log(error)
    }
}