Skip to content

Commit 42d9f1b

Browse files
committed
refactor: use string interpolation
1 parent c92f295 commit 42d9f1b

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

speech-to-text/get-models.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ module.exports = function getModels(options) {
5454
};
5555
var url = options.url || 'https://stream.watsonplatform.net/speech-to-text/api';
5656
if (options.access_token) {
57-
url = url + '/v1/models?access_token=' + options.access_token;
57+
url = `${url}/v1/models?access_token=${options.access_token}`;
5858
} else {
59-
url = url + '/v1/models?watson-token=' + options.token;
59+
url = `${url}/v1/models?access_token=${options.token}`;
6060
}
6161
return fetch(url, reqOpts)
6262
.then(function(response) {

text-to-speech/get-voices.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ module.exports = function getVoices(options) {
5555
};
5656
var url = options.url || 'https://stream.watsonplatform.net/text-to-speech/api';
5757
if (options.access_token) {
58-
url = url + '/v1/voices?watson-token=' + options.access_token;
58+
url = `${url}'/v1/voices?watson-token='${options.access_token}`;
5959
} else {
60-
url = url + '/v1/voices?watson-token=' + options.token;
60+
url = `${url}'/v1/voices?watson-token='${options.token}`;
6161
}
6262
return fetch(url, reqOpts)
6363
.then(function(response) {

text-to-speech/synthesize.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ module.exports = function synthesize(options) {
5151
var url = options.url || 'https://stream.watsonplatform.net/text-to-speech/api';
5252
var audio = options.element || new Audio();
5353
audio.crossOrigin = 'anonymous';
54-
audio.src = url + '/v1/synthesize?' + qs.stringify(pick(options, QUERY_PARAMS_ALLOWED));
54+
audio.src = `${url}/v1/synthesize?${qs.stringify(pick(options, QUERY_PARAMS_ALLOWED))}`;
5555
if (options.autoPlay !== false) {
5656
audio.play();
5757
}

0 commit comments

Comments
 (0)