Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6993425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:45:47+00:00 2026-05-27T19:45:47+00:00

I am trying to implement an autocompleter on a nodejs app using nowjs. everyone.now.sendAutocomplete

  • 0

I am trying to implement an autocompleter on a nodejs app using nowjs.

everyone.now.sendAutocomplete = function(search) {  
  var response = getAutocomplete(search);
  console.log("response");
  console.log(response);
};

which calls:

function getAutocomplete(search) {
    console.log(search);
    var artist = new Array();

    request({uri: 'http://musicbrainz.org/ws/2/artist/?query=' + search + '&limit=4', headers: "Musicbrainz Application Version 1"}, function(error, response, body) {
        par.parseString(body, function(err, result) {
            var count = result['artist-list']['@']['count'];

            var artists = result['artist-list']['artist'];
            // var artist = new Array();

            if (count > 1) {
            artists.forEach(function(a) {
                var att = a['@'];
                var id = att['id'];
                var name = a['name'];
                var dis = a['disambiguation'];

                if (dis) {
                    var display = name + " (" + dis + " )";
                } else {
                    display = name;
                }
                artist.push({'id':id, 'name': name, 'disambiguation':dis,
                                     'label':display, 'value':name, 'category':"Artists"});
            });
            //everyone.now.receiveResponse(artist);
            console.log("artist");
            console.log(artist);
            return artist;
        } else {
            console.log(artists);
            var att = artists['@'];
            var id = att['id'];
            var name = artists['name'];
            var dis = artists['disambiguation'];
            var resp = [{'id':id, 'name': name, 'disambiguation':dis,
                                 'label':name, 'value':name, 'category':"Artists"}];
            return resp;
            // everyone.now.receiveResponse([{'id':id, 'name': name, 'disambiguation':dis,
            //                       'label':name, 'value':name, 'category':"Artists"}]);
        }

        });
    });
}

However, console.log(response) says that response is undefined. I am new to node so the answer is probably simple, but still can’t figure it out.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:45:48+00:00Added an answer on May 27, 2026 at 7:45 pm

    You are treating the async call as synchronous. Your getAutocomplete needs to take a callback function to get the response. You’re using that a lot already, in your request call and your parseString call.

    Like this:

    everyone.now.sendAutocomplete = function(search) {  
        getAutocomplete(search, function (response) {
            console.log("response");
            console.log(response);
        });
    };
    

    And instead of return:

    function getAutocomplete(search, callback) {
        // ...
        callback(result);
        // ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement a live search on my photos site using jQuery and
trying to implement a dialog-box style behaviour using a separate div section with all
Trying to implement a UITableView of names similar to the built-in Contacts iPhone app
I am trying to implement a dynamic search jquery and php, but I am
Ok well I'm trying implement something similar to the 'undo' function in many image
I am trying to implement SO style autocomplete. I am using this gem to
I am trying to implement caching using jQuery UI autocomplete. I am using jQuery
i am creating a web project using JSP, and is trying to implement a
Trying to implement an autocomplete box ultimately. For now im following php academy's lead.
Hi I am trying to implement a autocomplete field using Zend Jquery. I followed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.