@@ -61,15 +61,17 @@ module.exports = function (RED) {
6161 version_date : '2016-12-15'
6262 } ) ;
6363
64- discovery . getCollections ( { environment_id : req . query . environment_id } ,
65- function ( err , response ) {
66- if ( err ) {
67- res . json ( err ) ;
64+ discovery . getCollections ( {
65+ environment_id : req . query . environment_id } ,
66+ function ( err , response ) {
67+ if ( err ) {
68+ res . json ( err ) ;
69+ }
70+ else {
71+ res . json ( response . collections ? response . collections : response ) ;
72+ }
6873 }
69- else {
70- res . json ( response . collections ? response . collections : response ) ;
71- }
72- } ) ;
74+ ) ;
7375 } ) ;
7476
7577 // API used by widget to fetch available collections in environment
@@ -80,18 +82,20 @@ module.exports = function (RED) {
8082 version_date : '2016-12-15'
8183 } ) ;
8284
83- discovery . query ( { environment_id : req . query . environment_id ,
84- collection_id : req . query . collection_id ,
85- count : 1 } ,
86- function ( err , response ) {
87- if ( err ) {
88- res . json ( err ) ;
85+ discovery . query ( {
86+ environment_id : req . query . environment_id ,
87+ collection_id : req . query . collection_id ,
88+ count : 1 } ,
89+ function ( err , response ) {
90+ if ( err ) {
91+ res . json ( err ) ;
92+ }
93+ else {
94+ var fieldList = discoveryutils . buildFieldList ( response ) ;
95+ res . json ( fieldList ) ;
96+ }
8997 }
90- else {
91- var fieldList = discoveryutils . buildFieldList ( response ) ;
92- res . json ( fieldList ) ;
93- }
94- } ) ;
98+ ) ;
9599 } ) ;
96100
97101 function Node ( config ) {
0 commit comments