googleapis / nodejs-vision

This repository is deprecated. All of its content and history has been moved to googleapis/google-cloud-node.
https://cloud.google.com/vision/
Apache License 2.0
495 stars 139 forks source link

helpers.js?cd8a:247 Uncaught TypeError: gax.GoogleProtoFilesRoot is not a constructor #431

Closed ChoyCheeWei closed 5 years ago

ChoyCheeWei commented 5 years ago

I try to implement Google Vision Api in Vuejs but I getting this error: helpers.js?cd8a:247 Uncaught TypeError: gax.GoogleProtoFilesRoot is not a constructor

this code is in my ocr.vue file <script> export default { name: "ocr" }; // Imports the Google Cloud client library const vision = require("@google-cloud/vision");

// Creates a client const client = new vision.ImageAnnotatorClient();

// Performs label detection on the image file client .textDetection('./resources/maybank2u.png') .then(result => { const labels = result[0].textAnnotations; console.log("Text:"); labels.forEach(text => console.log(text)); }) .catch(err => { console.error("ERROR:", err); }); </script>

Any idea how to solve this?

callmehiphop commented 5 years ago

👋 @ChoyCheeWei are you trying to use this on the front end? Currently this library doesn't support it, but I think we'll have a release out soon that will.

ChoyCheeWei commented 5 years ago

@callmehiphop I'm trying to get all the text from an image and store some of the text into database, but I already face some errors during my first step lol

callmehiphop commented 5 years ago

@ChoyCheeWei the latest release should have browser support if you'd like to try updating the client version and testing again.

bcoe commented 5 years ago

@alexander-fenster is there a canonical issue @callmehiphop, myself, and others can link folks to, related to browser support?

alexander-fenster commented 5 years ago

Maybe this one: https://github.com/googleapis/google-cloud-node/issues/2933

For Vision, helpers.js is a manual code that might also need to be updated to start using JSON protos (I haven't checked it yet).

alexander-fenster commented 5 years ago

This piece of code needs to be changed to use JSON protos. I will work on this.

https://github.com/googleapis/nodejs-vision/blob/4b8f23b3aec216c69f444c802dbeaf5fd8be665a/src/helpers.js#L247-L259