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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:31:17+00:00 2026-05-23T16:31:17+00:00

parseResponse = (response, cb) -> output = ” response.setEncoding(‘utf8’) response.on ‘data’, (chunk) -> output

  • 0
parseResponse = (response, cb) -> 
  output = ''
  response.setEncoding('utf8')
  response.on 'data', (chunk) -> output += chunk
  response.on 'end', ->
    j = JSON.parse(output)
    result = j.results[0]
    cb(result)

I’m trying to understand what this is doing and why it is necessary in a module I’m using. The response being passed in is from an http get.

Thanks

  • 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-23T16:31:18+00:00Added an answer on May 23, 2026 at 4:31 pm

    This function processes a response (instance of the ClientResponse class) being received via HTTP.

    response.setEncoding('utf-8')
    

    Indicates the desired transfer encoding (UTF-8). Chunks passed to the data event will be sent in this encoding.

    response.on 'data', (chunk) -> output += chunk
    

    Sets up a callback for processing data chunks. Each “chunk” of a string received is appended to the output string variable.

    response.on 'end', ->
    

    Sets another callback which acts on the completely transferred data.

    j = JSON.parse(output)
    result = j.results[0]
    

    The received data is assumed to be JSON and parsed as such. The first element of the parsed array is retrieved.

    cb(result)
    

    The callback cb originally provided to the function is called with this data found in the JSON object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I’m using JSON.parse on a response that sometimes contains a 404 response. In the
I am parsing a json string like so: ring = JSON.parse(response); Now, ring is
response = Typhoeus::Request.get(http://localhost:3000/api/api_email/#{@api_id}.json) JSON.parse(response.body) The response is a JSON object but I get an
I have request to webservice and getback xml result as output , In sucess
I have the following ajax call to webservice to pass json data and get
i know how to parse response like {\screenTitle\:\National Geographic\} token.optString(screenTitle); up to this ok.
I've JSON response from php file. [{ NAME: Kiev }, { NAME: Kiev metro
I'm trying to parse results from the YouTube API. I'm getting the results correctly
I am making a web service call and receiving a JSON formatted response. After
Could you help me to parse response correctly: Parser in - (void)request:(FBRequest *) request

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.