javascript - TypeError: callback is not a function - -


i have code part of wrapper pipl api , getting error:

this main code request , returns information api

looking forward getting helped :)

return callback(err, json.parse(body) || body); typeerror: callback not function 

what wrong here? how can solve error?

(function() {     var _ = require('lodash')         , request = require('request')         , util = require('util')         , url = require('url');      var handler = function(subclass) {         this.createcall = function(method, path, options, callback) {             return function(config) {                 if (_.isfunction(options)) {                     callback = options;                     options = {};                 }                 path = url.format({                     pathname: path,                     query: options                 });                 path = url.resolve(config.api_url, path);                 console.log(path)                  var parameters = {                     url: path,                     method: method                 };                  request(parameters, function(err, response, body) {                     return callback(err, json.parse(body) || body);                 });             }         };          _.merge(subclass, this);         return this;     }.bind(this);      module.exports = handler; }).call(this); 

the issue happening because search.query function accepts options , callback. in npm documentation says accepts type, options, callback

check guthub

this error means trying call function while not function, in case, problem sending options (which object) instead of callback (that should function)


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -