@@ -21,18 +21,20 @@ module.exports = function (RED) {
2121
2222 temp . track ( ) ;
2323
24- var username , password , sUsername , sPassword , language_translation ;
24+ var username , password , language_translation ;
2525
2626 var service = cfenv . getAppEnv ( ) . getServiceCreds ( / l a n g u a g e t r a n s l a t i o n / i) ;
2727
2828 if ( service ) {
29- sUsername = service . username ;
30- sPassword = service . password ;
29+ username = service . username ;
30+ password = service . password ;
3131 }
3232
3333 RED . httpAdmin . get ( '/watson-translate/vcap' , function ( req , res ) {
34- res . json ( service ? { bound_service : true } : null ) ;
35- } ) ;
34+ res . json ( service ? {
35+ bound_service : true
36+ } : null ) ;
37+ } ) ;
3638
3739 RED . httpAdmin . get ( '/watson-translate/models' , function ( req , res ) {
3840 language_translation = watson . language_translation ( {
@@ -67,11 +69,6 @@ module.exports = function (RED) {
6769 } ) ;
6870
6971 function SMTNode ( config ) {
70- RED . nodes . createNode ( this , config ) ;
71- var node = this ;
72-
73- username = sUsername || this . credentials . username ;
74- password = sPassword || this . credentials . password ;
7572 this . on ( 'input' , function ( msg ) {
7673 var message = '' ;
7774
@@ -124,8 +121,8 @@ module.exports = function (RED) {
124121 var trainid = msg . trainid || config . trainid ;
125122 var basemodel = msg . basemodel || config . basemodel ;
126123
127- username = sUsername || this . credentials . username ;
128- password = sPassword || this . credentials . password ;
124+ username = username || this . credentials . username ;
125+ password = password || this . credentials . password ;
129126
130127 if ( ! username || ! password ) {
131128 this . status ( {
@@ -166,6 +163,9 @@ module.exports = function (RED) {
166163 }
167164 } ) ;
168165
166+ RED . nodes . createNode ( this , config ) ;
167+ var node = this ;
168+
169169 this . doTranslate = function ( msg , model_id ) {
170170 node . status ( {
171171 fill : 'blue' ,
0 commit comments