So I'm trying to take a picture and populate the data in a list in a new screen. I'm getting a TypeError after I snap the picture.
Error [TypeError: undefined is not an object (evaluating 'jsonRes.responses[0]')]
Here is my code:
detectText(base64) {
fetch("https://vision.googleapis.com/v1/images:annotate?key=" + GOOGLE_CLOUD_KEYFILE, {
method: 'POST',
body: JSON.stringify({
"requests": [{
"image": { "content": base64 },
"features": [
{ type: "TEXT_DETECTION" }
]}]
})
})
.then(response => { return response.json() })
.then(jsonRes => {
let text = jsonRes.responses[0].fullTextAnnotation.text
this.props.navigation.navigate('ContactScreen', { text: text })
}).catch(err => {
console.log('Error', err)
})
}
When I snap the picture, the data should be gathered in a picker select list. Has been super frustrating and been trying for over 2 hours now, any help would be greatly appreciated.
Turns out Google Vision API was changed recently. Issue resolved.