Vision is not a constructor
See original GitHub issueI’m using the current release, and tried:
const {Vision} = require('@google-cloud/vision');
const token = {} //json for the google application credential
const vision = new Vision(token);
But it yields error that vision is not a constructor. What am I missing?
Issue Analytics
- State:
- Created 5 years ago
- Comments:18 (9 by maintainers)
Top Results From Across the Web
Uncaught TypeError: gax.GoogleProtoFilesRoot is not a ...
I'm trying to use google vision api to recognize the text in image main.js const vision = require("@google-cloud/vision"); // Creates a ...
Read more >TypeError: "x" is not a constructor - JavaScript - MDN Web Docs
The JavaScript exception "is not a constructor" occurs when there was an attempt to use an object or a variable as a constructor,...
Read more >Script Function JavaScript Source Code and API ...
Constructor. The JavaScript source code must set a "module.exports" equal to a function that represents the constructor of the tool. This function will...
Read more >Javascript "Not a Constructor" Exception while creating objects
JavaScript : Javascript " Not a Constructor " Exception while creating objects [ Gift : Animated Search Engine : https://bit.ly/AnimSearch ] ...
Read more >ImageUrl Constructors - Custom Vision Prediction
ImageUrl Constructors. Reference. Feedback ... Vision.CustomVision.Prediction.Models. Assembly: Microsoft.Azure.CognitiveServices.Vision.CustomVision.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@bcoe @JustinBeckwith FYI - the codelab example is out of date
Ah, I inspected the ImageAnnotatorClient export and see where the credential can be passed in as an option of that class constructor:
So, I implemented as thus which seems to work fine:
This seems to work fine, but it does go against some documentation I read earlier (see the Passing the path to the service account key in code). It describes:
Event though it describes the storage API, I took this to mean that vision also exported a “vision” class which accepts a credential object just like storage, but this is not the case and had me confused.
I suggest changing the wording of “All clients in google-cloud-node have this” for clarity.