[Vue警告]:创建的挂钩中出现错误:“错误:{” clientConfig“:{},” port“:443,” servicePath“:” vision.googleapis.com“,” scopes“:

时间:2019-09-24 12:12:48

标签: node.js vue.js google-vision

我尝试在 Vuejs 中实现 google vision API ,但出现此错误:

[Vue warn]: Error in created hook: "Error: {"clientConfig":{},"port":443,"servicePath":"vision.googleapis.com","scopes":["https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/cloud-vision"]}You need to pass auth instance to use gRPC-fallback client in browser. Use OAuth2Client from google-auth-library."

我从图片中读取文字的代码:

// 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('./myimage.png')
.then(result => {
 const texts = result[0].textAnnotations;
 console.log('Text:');
 texts.forEach(text => console.log(text.description));
 })
.catch(err => {
 console.error('ERROR:', err);
 });

任何想法如何解决?

0 个答案:

没有答案