I have successful to connect my react native app with MySQL server if I try the code that I implement using laptop web it works well all the data I enter it will store into the database that I have created but when I run on my android device it can't store the data into the database
export default class Scanner extends Component{
constructor(props) {
super(props);
this.state = {userid: ''};
}
Register = () => {
let userid = this.state.userid;
let InsertAPIURL = "https://localhost/api/insert.php";
let headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Access-Control-Allow-Methods': 'POST, PUT, PATCH, GET, DELETE, OPTIONS',
'Access-Control-Allow-Headers': 'Origin, X-Api-Key, X-Requested-With, Content-Type, Accept, Authorization',
}
let Data = {
userid: userid,
};
fetch(InsertAPIURL, {
mode:'no-cors',
method: 'POST',
headers: headers,
body: JSON.stringify(Data)
})
try{
((response) =>response.json()),
((response)=>{
alert(response[0].Message);
})
}
catch{
((error) => {
alert("Error"+error);
})
}
}
render(){
return(
<View style={styles.ViewStyle}>
<TextInput
placeholder={"Member No"}
placeholderTextColor={"tomato"}
keyboardType={"numeric"}
style={styles.txtStyle}
onChangeText={userid => this.setState({userid})}
/>
<Button
title={"Register"}
onPress={this.Register}
/>
</View>
);
}
}
the problem probably happen on the URL but how should I edit it.