2016-09-22 37 views
7

nodejs için Microsoft Cognitive Services api kullanıyorum. Bu kod aşağıdaki olsun hataTypeError: cognitiveServices.face bir kurucu değil

const face = new cognitiveServices.face({ 
      ^

    TypeError: cognitiveServices.face is not a constructor 
     at Object.<anonymous> (/Users/..../face.js:3:14) 
     at Module._compile (module.js:556:32) 
     at Object.Module._extensions..js (module.js:565:10) 
     at Module.load (module.js:473:32) 
     at tryModuleLoad (module.js:432:12) 
     at Function.Module._load (module.js:424:3) 
     at Module.runMain (module.js:590:10) 
     at run (bootstrap_node.js:394:7) 
     at startup (bootstrap_node.js:149:9) 
     at bootstrap_node.js:509:3 

nasıl bu hatayı giderebilirsiniz yürütmek zaman, kod ancak

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); 
     }); 

aşağıdaki mı? Bu cognitive-services modülü belgelerine benziyor

+0

Bir sağ, o modülün üzerinde açıklama gerektiren var? Sorunuzu bu ifadeyi içerecek şekilde düzenleyebilir misiniz? Benzer şekilde, Kurulum ve Başlarken adımlarına göre bilişsel hizmetlerini doğru şekilde yüklediğinizi doğrulamak iyi olur. Https://github.com/joshbalfour/node-cognitive-services#installation. – ArthurDenture

+0

Evet Bunu aldım ve sorumu güncelledim. – 2619

+0

Merhaba, cevabım sizin için mi çalıştı? Ben kelle hala açık olduğunu görüyorum ... – ArthurDenture

cevap

5

yanlıştır: Eğer new olmadan cognitiveServices.face(...) çağırmanız gerekir.

https://github.com/joshbalfour/node-cognitive-services/blob/master/api/face.js'a bakarsanız, face'un bir ok işlevi olarak tanımlandığını görebilirsiniz, bu da yapıcı olmadığını gösterir. Durumun neden olduğuyla ilgili ayrıntılar için bkz. https://stackoverflow.com/a/37037600/483595.

Düzenleme: sorun gibi görünüyor zaten burada bildirilmektedir: https://github.com/joshbalfour/node-cognitive-services/issues/2

+0

Bu hata düzeltildi :) –

İlgili konular