Skip to content

undefined is not a function  #87

@Darshan972

Description

@Darshan972

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);
});
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions