1

I have a .net WebApi, and the get method at https://localhost:7162/Collection/get-collections. I am trying to connect a react android app to this WebApi, but I can't fetch the data.

    fetch('https://localhost:7162/Collection/api/get-collections')
      .then(res => res.json())
      .then(data => setItems([...new Set(data.map(item => item.name))]
        .map(name => ({
          label: name,
          value: name,
        }))))
        .catch(function(error) {
          console.log('There has been a problem with your fetch operation: ' + error.message);
           // ADD THIS THROW error
            throw error;
          });;
  }, []);

When I run it, I get

Possible Unhadled Promise Rejection (id: 0);
 TypeWrror: Network request failed

Any ideas on how to connect the C# backend to the react mobile?

  • Does this answer your question? [React Native Android Fetch failing on connection to local API](https://stackoverflow.com/questions/33704130/react-native-android-fetch-failing-on-connection-to-local-api) – user18309290 Jan 15 '23 at 06:37

0 Answers0