fairly new to all this but I'm trying to get my React Native app to connect to a .NET Core API running on my localhost. I want to test on an iPhone so to connect I am using the QR code that is generated when starting the React Native app using Expo Client
The URL I tried using to connect to the API is:
https://localhost:51787
I also tried using the local IP address from Ipconfig
http://192.168.1.69:51787
And from another post that suggested trying this for iPhones :
http://10.0.2.2:51787
This is how I'm using it :-
const login = () => {
fetch('https://localhost:51787/api/Login?username=' + username + '&password=' + password, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
}
})
.then((response) => response.json())
.then((responseJson) => {
// Do stuff here
})
.catch((error) => {
console.error(error);
});
}
Unfortunately the URLs that I tried do not work and I get the error 'Network Request Failed'
I have enabled Cross-Origin Request.
Can anyone point me in the right direction, thanks