javascript - TypeError: cognitiveServices.face is not a constructor -


i using microsoft cognitive services api nodejs. have following code

  const cognitiveservices = require('cognitive-services');    const face = new cognitiveservices.face({       api_key: yourapikey   })    const parameters = {       returnfaceid: "true"       returnfacelandmarks: "false"   };   const body = {       "url": "url of input image"   };     face.detect({           parameters,           body       })       .then((response) => {           console.log('got response', response);       })       .catch((err) => {           console.error('encountered error making request:', err);       }); 

however, when execute code following error

  const face = new cognitiveservices.face({                ^    typeerror: cognitiveservices.face not constructor       @ object.<anonymous> (/users/..../face.js:3:14)       @ module._compile (module.js:556:32)       @ object.module._extensions..js (module.js:565:10)       @ module.load (module.js:473:32)       @ trymoduleload (module.js:432:12)       @ function.module._load (module.js:424:3)       @ module.runmain (module.js:590:10)       @ run (bootstrap_node.js:394:7)       @ startup (bootstrap_node.js:149:9)       @ bootstrap_node.js:509:3 

how can resolve error?

it looks documentation cognitive-services module incorrect: need call cognitiveservices.face(...) without new.

if @ https://github.com/joshbalfour/node-cognitive-services/blob/master/api/face.js, can see face defined arrow function, makes not constructor. see https://stackoverflow.com/a/37037600/483595 details on why case.

edit: looks issue reported here: https://github.com/joshbalfour/node-cognitive-services/issues/2


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -