i am getting a 404 and another error when i try to run my app, it is a face recognition api from clarifai
TypeError: Cannot read properties of undefined (reading ‘0’)
at App.calculateFaceLocation (App.js:82:1)
at App.js:128:1
this is the second error can anyone help this is a code snippet
onButtonSubmit = () => {
this.setState({imageUrl: this.state.input});
app.models.predict('face-detection', req.body.input)
fetch('http://localhost:3000/imageurl', {
method: 'post',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
input: this.state.input
})
})
.then(response => response.json())
.then(response => {
if (response) {
fetch('http://localhost:3000/image', {
method: 'put',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
id: this.state.user.id
})
})
.then(response => response.json())
.then(count => {
this.setState(Object.assign(this.state.user, { entries: count }))
})
.catch(console.log)
}
this.displayFaceBox(this.calculateFaceLocation(response))
})
.catch(err => console.log(err));
}
in the console i get an error in the first fetch line imageurl
i tried using chat gpt but i get no errors when debugging the code i tried the old way and the new way of using the clarifai api and i get the same error
2
Answers
The issue seems to be unrelated with how you implement the Clarifai API. It seems you are trying to access a variable that you have not declared yet. Ensure the data from Clarifai is loaded before trying to access it.