-
-
Notifications
You must be signed in to change notification settings - Fork 176
Description
Hey, i amm getting an error after calling an function after onPressesd , that "undefined is not a function near setInterval".
please see it.
here is the code of 1'st file where i am calling it:
<Icon style = {styles.icon}
name = 'search'
type = 'material'
color= 'black'
onPress = {() => {
this.setState({channelId: this.getChannelId(this.state.term)});
obj.onPressedButton(this.state.channelId);
}
}
/>
here is the another file from where i am calling this:
return (
<TouchableOpacity style = {styles.btn} onPress = { () =>
{
obj.onPressedButton(channelId);
}
}>
);
here is the function defination in another file:
onPressedButton = channelId =>
{
// fetch the value entered in the input field
//alert(channelId);
this.setState({channelId:channelId})
//fetch the value(channelId) that is enter in the input field
// make a request
var url = 'https://www.googleapis.com/youtube/v3/channels?key='+API_Key+'&id=' + this.state.channelId + '&part=snippet,contentDetails,statistics';
this.setState({url: url});
fetch(url,{
method: 'GET'
})
.then((response) => response.json())
// fetchData(data);
.then((data) => {
fetchData(data);
alert(imgLink);
})
//now fetching the response from the yt api again and again
.setInterval(() =>
{
var url = 'https://www.googleapis.com/youtube/v3/channels?key='+API_Key+'&id=' + this.state.channelId + '&part=statistics';
fetch(url,{
method: 'GET'
})
.then((response) => updateSubscribers(response.json()))
},0)
.catch((error) => {
console.log(error);
});
}