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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:21:46+00:00 2026-06-17T09:21:46+00:00

In Backbone.js, I’m working with an API which wraps the response in a meta

  • 0

In Backbone.js, I’m working with an API which wraps the response in a meta and data hash. For example:

# GET /api/posts/1
meta: {
  status: 200
},
data: {
  id: 1
  title: 'Hello World'
}

# GET /api/posts
meta: {
  status: 200
},
data: [
  {
    id: 1
    title: 'Hello World'
  },
  { 
    id: 2
    title: 'Hi everyone!'
  }
]

My Backbone.js Collection/Models have the following parse function overwritten:

# App.Models.Post
... 
parse: function (response) {
   this.meta = response.meta;
   return response.data;
}

# App.Collections.Posts
... 
parse: function (response) {
   this.meta = response.meta;
   return response.data;
}

However, when I fetch on the collection posts = new App.Collections.Posts(); posts.fetch(), the post attributes are all empty. I.e. posts.at(0).get('title') = undefined.

Now, this is fixed when the Model parse is changed to:

parse: function (response) {
   return response;
}

But this means that post.fetch() is broken.
Any suggestions?

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-06-17T09:21:46+00:00Added an answer on June 17, 2026 at 9:21 am

    I think the problem is that your model’s parse is getting inconsistent data passed into it when done via model fetch vs collection fetch. console.log the argument to model parse to confirm this. This is because the value return by collection’s parse is just an array of object data and to convert those to models, the collection just delegates to the model’s parse method. This might fix your issue:

    //App.Models.Post
    parse: function (response) {
        if (response.data) {
            return response.data;
        }
        return response;
    }
    

    For reference: https://github.com/documentcloud/backbone/pull/773

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

Sidebar

Related Questions

I'm working with backbone and lazy-loading both templates and data for one of my
My Backbone app includes Views which depend on multiple models. For example, I define
I have a simple backbone.js example I am working on. The problem is upon
In Backbone, I have a collection which is populated with some JSON data which
Backbone.js provides a navigate(fragment, [options]) method for its Backbone.router objects, which does the following
In Backbone.js I can appoint where the model fetches it's data: var Book =
A Backbone app which I'm developing has a collection and a model, and associated
Working in Backbone.js, I'd like to set a model property from within a method
I'm saving a backbone.js model using the model.save() method, which fires a PUT request
In backbone it seems that I have to get model attributes via model.get('att_name') I'd

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.