0

One of my friend has this issue, we are hosting the api using lite-server, and access the api on browser, it says callback is not a function.

   'use strict';
    (function () {
         var StoreAPI = require('Store');
         module.exports = {            
             getBooks: function (event, context,callback) {
                 var books;
                    StoreAPI.getAll('books', function(err,data){                 
                     console.log(data);    
                     callback({
                         path: data.path, 
                         error: false, 
                         errorCode: 0, 
                         body: { 
                         books : data    
                         }           
                     });           
                 });
            }
        };
    } ());

url goes as:

http://localhost:3000/getBooks

1 Answer 1

2

This issue is likely caused by the code that invokes getBooks.

After the API call is completed, you try to call the function passed in as parameter callback, but as the error message says, what you are trying to call is not a function. To resolve this, ensure that the invoking code actually passes a function as callback.

Sign up to request clarification or add additional context in comments.

1 Comment

@Sajeetharan you can't do that "in a browser url". Perhaps you need to include more information in your question about what you are doing and what you are trying to achieve.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.