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 8120131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:01:33+00:00 2026-06-06T05:01:33+00:00

My problem actually is that I was using the response body before the callback

  • 0

My problem actually is that I was using the response body before the callback was called, which resulted in an error and therefore the callback was never called.

I am using request module, though this problem seems to happen with any callback.

If I do something like this.

var request = require('request');

module.exports.test = function ()
{
    request('http://www.google.com', function (error, response, body) {
        /**
         * This callback doesn't seem to ever be called.
         */

        console.log(body);
    });
};

And use it like.

var mytest = require('./test.js');

mytest.test();

The callback doesn’t seem to ever be called.

  • 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-06-06T05:01:36+00:00Added an answer on June 6, 2026 at 5:01 am

    Your code is working as expected and if you don’t see any output that means some error had place which should be indicated in error argument passed to your function.

    var request = require('request');
    request('http://www.google.com', function (error, response, body) {
      if (!error && response.statusCode == 200) {
        console.log(body) // Print the google web page.
      } else {
        console.log('error: '+ response.statusCode)
      }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm facing following problem actually: I'm using Spring with jQuery. I have Controller: @Controller
Problem: Fragment onResume() in ViewPager is fired before the fragment becomes actually visible. For
I've got a class called Request . At some point in that class I
When do I actually get my response code 200 for a valid request for
I posted before but now I seem to actually see the problem, just having
Problem This question actually came up at work today. We are planning an experiment
Actually my problem is sometimes i can get the location and sometimes i can't
Actually I am confronted with a Problem. I've got a .apk-File in one Package
I am actually after some ideas to how to address my problem below: I
actually, problem solved. I made a mistake putting mysql_real_escape() for the post value, so

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.