Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16552

React Native / Expo iOs - Network Request Failed with Fetch on my Api

$
0
0

Firstly : i went through many ( MANY ) post about this problem, tested them all, but it seems that i'm cursed, or something like that ?

I'm working on expo with the LAN method, on iOs.My back is on .Net Core 3.My iPhone is on the same Wifi than my computer.And my computer is running my .Net back server.

I found at that localhost cannot be handle by expo/react-native. So i tried the IP adresse method and change my back adress and the adress that my front was trying to fetch.Tried the infoPlist with expo. Tried some mysterious things that i don't fully understood with my .Net server. Also tried to turn off my firewall, it didn't change anything.Well, i'm not used to post because existing posts often answer my question.

Here is my code about my fetch method :

export async function callPlanning() {    try {        let response = await fetch("http://my.Ipv4.adress:myApiPort/myRoute",        );        let responseJson = await response.json();        return responseJson;      } catch (error) {        console.error(error);      }}

My Api is working well on Postman.And i can call the facebook test api with this function within my app.

Here is my app code where i'm calling this fetch function :

export default class BetaserieScreen extends Component {  constructor(props) {    super(props)    this.state={      response: null,    };    this.askPlanning = this.askPlanning.bind(this);  }  askPlanning = () => {    this.setState({      response: Back.callPlanning(),    })  }  render() {    return (<View style={styles.MainContainer}><Text> Beta Serie </Text><TouchableHighlight onPress={this.askPlanning}><Text>Planning</Text></TouchableHighlight></View>    );  }}

If you see anything that could andwer my question or about my code : i'll take it.I'm on it for 2 days, and i've to find a solution...If you need any other information about my system or file about my project, feel free to ask for it if you think you can help me with this problem.

I'll be glad.


Viewing all articles
Browse latest Browse all 16552

Trending Articles