52107
Node.jsでwatsonのAPIを実行しようとすると次のようなエラーが出てしまいます。

```

    TypeError [ERR_HTTP_INVALID_HEADER_VALUE]: Invalid value "undefined" for header "authorization"
        at ClientRequest.setHeader (_http_outgoing.js:473:3)
        at new ClientRequest (_http_client.js:194:14)
        at Object.request (https.js:281:10)
        at WebSocketClient.connect (/Users/sodeimo/node_modules/websocket/lib/WebSocketClient.js:254:56)
        at new W3CWebSocket (/Users/sodeimo/node_modules/websocket/lib/W3CWebSocket.js:62:18)
        at RecognizeStream.initialize (/Users/sodeimo/node_modules/watson-developer-cloud/lib/recognize-stream.js:201:37)
        at /Users/sodeimo/node_modules/watson-developer-cloud/lib/recognize-stream.js:399:23
        at RecognizeStream.setAuthorizationHeaderToken (/Users/sodeimo/node_modules/watson-developer-cloud/lib/recognize-stream.js:475:13)
        at RecognizeStream._write (/Users/sodeimo/node_modules/watson-developer-cloud/lib/recognize-stream.js:374:14)
        at doWrite (_stream_writable.js:410:12)
    
```

具体的に該当箇所を見ても、自分が手を加えたわけではなく何が間違っているのかよく分からず困っています…  
実行しているコードは次の通りです。（APIキーは変えています）

```

    'use strict';
    require('dotenv').config({ silent: true }); // optional, handy for local development
    var SpeechToText = require('watson-developer-cloud/speech-to-text/v1');
    var LineIn = require('line-in'); // the `mic` package also works - it's more flexible but requires a bit more setup
    var wav = require('wav');
    
    var speechToText = new SpeechToText({
        url:'https://stream.watsonplatform.net/speech-to-text/api',
        api_key:'hoge'
    
    });
    
    var lineIn = new LineIn(); // 2-channel 16-bit little-endian signed integer pcm encoded audio @ 44100 Hz
    
    var wavStream = new wav.Writer({
        sampleRate: 44100,
        channels: 2,
    });
    
    var recognizeStream = speechToText.recognizeUsingWebSocket({
        content_type: 'audio/wav',
        interim_results: true
    });
    
    lineIn.pipe(wavStream);
    
    wavStream.pipe(recognizeStream);
    
    recognizeStream.pipe(process.stdout);
    
```

Nodeの実行環境は整っていて、npmパッケージのインストールはできています。  
何か分かる方がいらっしゃいましたらご教授いただけると助かります。よろしくお願いします。
CC BY-SA 4.0
2019-01-19T05:20:29.037
52105
2019-01-19T05:56:47.127
31801
question
node.js watson-api
Node.jsのTypeError [ERR_HTTP_INVALID_HEADER_VALUE]
api_keyではなくiam_apikeyとすれば解決しました
CC BY-SA 4.0
2019-01-19T05:56:47.127
52107
2019-01-19T05:56:47.127
31801
52105
answer