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?