I have a react component that makes an api call based on the data recieved by its props.
constructor(props) {
super(props);
this.state = {
followsUser: null
}
componentDidMount() {
console.log(this.props)
axios.get(`http://127.0.0.1:8000/users/check/${this.props.id}`)
.then(res => this.setState({ followsUser: res.data.follows }))
.catch(err => console.log(err))
}
I call the component in another component like:
<FollowButton key={this.state.user.id} id={this.state.user.id} />
But in the browser console I get the following error:
GET http://127.0.0.1:8000/users/check/undefined 404 (Not Found)
This is what I see in the browser console: console