Hello, I'm making iOS application with react-native. I'm using external server to check some data, so I allowed all of http request in Info.plist
file.
But as you can see, in console of screen shot, Promise Rejection - Network Error occurred.
same code in Android, it works well.
I tested it in iOS simulator and real device, both failed.
Can you help me what is problem.
Thanks.
the http code part is like this, this works well in Android emulator.
axios.get('http://suggest.hub.daum.net/suggest?q='+query+'&mod=json&code=utf_in_out&callback=suggestCallback&id=54')
.then((response) => {
...
});
plus...
this is full code.
findStock = (query, cb) => {
console.log('find stock ' + query);
if (query === '') {
console.log('set default sgs');
this.setState({suggestions: []})
return [];
}
else {
axios.get('http://suggest.hub.daum.net/suggest?q=' + query + '&mod=json&code=utf_in_out&callback=suggestCallback&id=54')
.then((response) => {
console.log(response);
var suggestions = (JSON.parse(response.data.substring(0, response.data.length - 2).replace('suggestCallback (', '')).items);
cb(suggestions);
})
.catch((error) => {
console.log(error);
throw error;
});
}
};
render() {
var that = this;
const comp = (a, b) => a.toLowerCase().trim() === b.toLowerCase().trim();
var _saveCondition = (stock, types, filters) => {
Keyboard.dismiss();
this.props.onStartCreateCondition(stock, types, filters);
};
return (
<View style={{ flex: 1, justifyContent: 'flex-start', backgroundColor: '#3e63bc'}}>
<HeaderComponent showToPrevious={true}/>
<View style={{ padding: 30, zIndex: 10 }}>
<View style={{ marginBottom: 25 }}>
<Text style={{ color: '#fff', fontSize:15}}>알림 조건 추가</Text>
</View>
<View style={{ flexDirection: 'row', zIndex: 2, height: 45, alignItems: 'center' }}>
<View style={{ justifyContent: 'center', height: 100}}>
<Icon
name='search'
color='#fff'
size={25}
/>
</View>
<Autocomplete
style={{ marginLeft:0, paddingLeft:0, fontSize: 14, height:34, color: '#afc5da' }}
containerStyle={{ marginLeft: 10, flex: 1, height:40}}
inputContainerStyle={{ marginLeft:0, paddingLeft:0, borderWidth: 0, borderBottomWidth: 1, borderBottomColor: '#afc5da', }}
listContainerStyle={{ marginTop:-10, paddingTop:0 }}
listStyle={{ margin: 0, backgroundColor: '#afc5da' }}
data={this.state.suggestions.length === 1 && comp(this.state.query, this.state.suggestions[0]) ? ['aaaaa'] : this.state.suggestions}
defaultValue={this.state.query}
onChangeText={(text) => {
this.setState({ query: text});
this.findStock( text, function(sgs) {
that.setState({suggestions : sgs})
});
}}
placeholder="종목명을 입력하세요."
placeholderTextColor={'#afc5da'}
renderItem={data => (
<TouchableOpacity onPress={() => {
this.setState( { query: data });
that.setState({ suggestions : []})
Keyboard.dismiss();
}}>
<Text>{data}</Text>
</TouchableOpacity>
)}
/>
</View>
....