function makeQuery(params) {
  const discovery = new DiscoveryV1({
    version: '2017-08-01'
  })

  // Using a Promise to allow the use of async/await in other code, this allows calls without callback hell which is important in
  // finding the correct collection, it requires both the environment and a discovery instance.
  return new Promise(async (resolve, reject) => {
    // Watson News now uses pre-defined env and coll id values
    params.environment_id = 'system'
    params.collection_id = 'news'

    // The SDK isn't setup for promises, wrapping in one so that we may use async/await with other calls to these functions
    discovery.query(params, (error, data) => {
      if (error) {
        reject(error)
      } else {
        resolve(data)
      }
    })
  })
}
// All the params are passed straight through.
All the params are passed straight through.
All the params are passed straight through .
function makeQuery(params) {
  const discovery = new DiscoveryV1({
    version: '2017-08-01'
  })
  return new Promise(async (resolve, reject) => {
    params.environment_id = 'system'
    params.collection_id = 'news'
    discovery.query(params, (error, data) => {
      if (error) {
        reject(error)
      } else {
        resolve(data)
      }
    })
  })
}
function makeQuery ( params ) { const discovery = new DiscoveryV1 ( { version : '2017-08-01' } ) return new Promise ( async ( resolve , reject ) => { params . environment_id = 'system' params . collection_id = 'news' discovery . query ( params , ( error , data ) => { if ( error ) { reject ( error ) } else { resolve ( data ) } } ) } ) }
All the params are passed straight through.
All the params are passed straight through .
// Using a Promise to allow the use of async/await in other code, this allows calls without callback hell which is important in // finding the correct collection, it requires both the environment and a discovery instance. // Watson News now uses pre-defined env and coll id values // The SDK isn't setup for promises, wrapping in one so that we may use async/await with other calls to these functions