0
votes

I am not entering my if (!error) statement, I know this because my console.log('in query') statement is not printing.

var express = require('express');
var fs= require('fs');
var request = require('request');
var cheerio = require('cheerio');
var app = express();
var crunchbase = require('crunchbase2');
var apikey='myapikey';

crunchbase.init(apikey);
console.log('after init');

crunchbase.people( {query: "1" }, function(error, results) {
  console.log('in .people');
    if (!error) {
      console.log('in query');
      console.log(results) // Print the search results                                              
  }
});

Any ideas? Thanks.

more details on error:

SyntaxError: Unexpected end of input at Object.parse (native) at Request._callback (/home/ubuntu/crunchbase/node_modules/crunchbase2/index.js:73:28) at Request.self.callback (/home/ubuntu/crunchbase/node_modules/request/request.js:198:22) at Request.emit (events.js:98:17) at Request. (/home/ubuntu/crunchbase/node_modules/request/request.js:1035:10) at Request.emit (events.js:117:20) at IncomingMessage. (/home/ubuntu/crunchbase/node_modules/request/request.js:962:12) at IncomingMessage.emit (events.js:117:20) at _stream_readable.js:944:16 at process._tickCallback (node.js:448:13)

1
note: myapikey contains my actual key. Specifically the error is "unexpected token"dstung

1 Answers

0
votes

It seems that you are reaching till "in .people"

debug it by checking the value of error variable and then change you if condition like one i provided

var express = require('express');
var fs= require('fs');
var request = require('request');
var cheerio = require('cheerio');
var app = express();
var crunchbase = require('crunchbase2');
var apikey='myapikey';

crunchbase.init(apikey);
console.log('after init');

crunchbase.people( {query: "1" }, function(error, results) {
  console.log('in .people');
  console.log(error);
    if (error) {
      console.log('in query');

  }
console.log(results) // Print the search results   
});

this might be a better way to code and as your information you have a error variable that contain some information so your if condtion not working