Guest User

Untitled

a guest
Feb 13th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. var DiscoveryV1 = require('watson-developer-cloud/discovery/v1');
  2.  
  3. /**
  4. * Queries a Watson Discovery collection
  5. *
  6. * @param {String} username
  7. * @param {String} password
  8. * @param {String} environment_id
  9. * @param {String} collection_id
  10. * @param {String} query
  11. *
  12. * @returns {Promise}
  13. */
  14.  
  15. function main(params) {
  16.  
  17. var discovery = new DiscoveryV1({
  18. username: params.username,
  19. password: params.password,
  20. version_date: '2017-11-07'
  21. });
  22.  
  23. return new Promise(function(resolve, reject) {
  24. discovery.query({
  25. environment_id: params.environment_id,
  26. collection_id: params.collection_id,
  27. query: params.query
  28. }, function(err, response) {
  29. if (err) {
  30. console.error(err);
  31. reject(err);
  32. } else {
  33. resolve(response);
  34. }
  35. });
  36. });
  37. }
Add Comment
Please, Sign In to add comment