2017-06-22 101 views
0

「渲染」當我運行微軟圖形API Node.js的代碼示例中,我得到這個:類型錯誤:無法讀取屬性未定義

https://developer.microsoft.com/en-us/graph/graph/quick-start

有誰知道如何解決它?

感謝

節點:6.11.0 NPM:5.0.3

> [email protected] start C:\Users\me\Desktop\Apps\AI-Work 
> mocha ./tests/confTest.js && node ./bin/www 



    ADAL 
    √ Checking clientID and clientSecret in config.js 


    1 passing (14ms) 

{"name":"AzureAD: OIDC Passport Strategy","hostname":"DESKTOP-Q841CUJ","pid":67868,"level":40,"msg":"Production environments should always validate the issuer.","time":"2017-06-22T23:06:46.715Z","v":0} 
{"name":"AzureAD: OIDC Passport Strategy","hostname":"DESKTOP-Q841CUJ","pid":67868,"level":40,"msg":"Using http for redirectUrl is not recommended, please consider using https","time":"2017-06-22T23:06:46.720Z","v":0} 

Listening on port 3000 
GET/304 160.625 ms - - 
GET /stylesheets/style.css 304 5.216 ms - - 
GET /img/favicon.ico 304 1.561 ms - - 
GET /login 302 661.892 ms - 0 
GET /token?code=------------------------------------------------------------------------------ 200 1672.604 ms - 2020 
GET /stylesheets/style.css 304 2.921 ms - - 
GET /img/favicon.ico 304 2.740 ms - - 
C:\Users\me\Desktop\Apps\AI-Work\routes\index.js:139 
    res.render('error', { 
    ^

TypeError: Cannot read property 'render' of undefined 
    at renderError (C:\Users\me\Desktop\Apps\AI-Work\routes\index.js:139:6) 
    at graphHelper.getProfilePhoto (C:\Users\me\Desktop\Apps\AI-Work\routes\index.js:73:19) 
    at request.get.set.end (C:\Users\me\Desktop\Apps\AI-Work\utils\graphHelper.js:35:6) 
    at Request.callback (C:\Users\me\Desktop\Apps\AI-Work\node_modules\superagent\lib\node\index.js:688:3) 
    at C:\Users\me\Desktop\Apps\AI-Work\node_modules\superagent\lib\node\index.js:883:18 
    at IncomingMessage.<anonymous> (C:\Users\me\Desktop\Apps\AI-Work\node_modules\superagent\lib\node\parsers\json.js:16:7) 
    at emitNone (events.js:91:20) 
    at IncomingMessage.emit (events.js:185:7) 
    at endReadableNT (_stream_readable.js:974:12) 
    at _combinedTickCallback (internal/process/next_tick.js:80:11) 
npm ERR! code ELIFECYCLE 
npm ERR! errno 1 
npm ERR! [email protected] start: `mocha ./tests/confTest.js && node ./bin/www` 
npm ERR! Exit status 1 
npm ERR! 
npm ERR! Failed at the [email protected] start script. 
npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 

npm ERR! A complete log of this run can be found in: 
npm ERR!  C:\Users\me\AppData\Roaming\npm-cache\_logs\2017-06-22T23_07_03_252Z-debug.log 

回答

0

這看起來像一個類似的問題,到一個我回答到這裏:我們已經報道https://stackoverflow.com/a/44464060/2517012

這些問題發送給Microsoft的相應團隊,他們正在更新樣本。

對於這個問題,renderError()需要兩個參數 - 錯誤和響應對象。您可能因爲renderError僅使用一個參數調用而在res.render()上觸發呈現未定義的渲染。正如我在上面提到的答案中所提到的那樣,我建議設置斷點來查看renderError方法被調用的原因。

相關問題