Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

query function is not defined. #2

Open
sarnathkj opened this issue Jul 12, 2017 · 2 comments
Open

query function is not defined. #2

sarnathkj opened this issue Jul 12, 2017 · 2 comments
Labels

Comments

@sarnathkj
Copy link

sarnathkj commented Jul 12, 2017

mP.query is not a function. I see "Query" is exported in the lib. I've mP variable properly declared and assigned and could see the below objects for the mP Object. Please advise.

mP Object:

mPulse {
  connect: [Function],
  connectByApiToken: [Function],
  createObject: [Function],
  getObjectByID: [Function],
  objectExists: [Function],
  queryObjects: [Function],
  updateObject: [Function],
  deleteObject: [Function],
  readSeedData: [Function],
  readSeedDataStream: [Function],
  appendSeedData: [Function],
  appendSeedDataStream: [Function],
  truncateSeedData: [Function],
  disconnect: [Function],
  asPromises: [Function],
  Query:
   Query {
     endpoint: 'https://mpulse.soasta.com/concerto/mpulse/api/v2',
     apiKey: '<api-key>' },
  mPulse: [Function],
  setApiKey: [Function] }

Sample Invocation.

// Require the mPulse class
var mPulse = require("mpulse-query").mPulse;

// Access mPulse API for mpulse.soasta.com
var mP = new mPulse(conf.soasta.apiKey);
mP.query("summary", {date: "today"}, function(err, result) {
  if (err) {
    console.log(err.message);
    return;
  }

  logger.info(result);
  console.log(result);
});
@andreas-marschke
Copy link
Contributor

Hi @sarnathkj

Looking at your sample code you've missed to invoke mPulse.connect() or mPulse. connectByApiToken() to generate an Auth Token and be allowed to request data from the service.

Please ensure that you have valid auth-credentials and try to use one of the connect functions to first get a token and then try to retrieve the API Data you wish to retrieve.

Kind regards,

Andreas Marschke.

@andreas-marschke
Copy link
Contributor

Having checked the docs. I apologize that this has not been explicitly called out there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants