Skip to content
This repository was archived by the owner on Jan 26, 2021. It is now read-only.
This repository was archived by the owner on Jan 26, 2021. It is now read-only.

Can't get objects from Parse #190

@Tim77277

Description

@Tim77277

Hi I tried to use the example code on your README and changed the Parse Class Name to get the desired objects, but it crashes in render function "this.data.ads.map". It gives the message "can not call map of undefined". Does it means that Parse.Query did not get trigger? I have tried to use the Parse JS SDK and got the objects with no issue so I think this issue is not something related to configuration.

import React, { Component } from 'react';
import Parse, {Query} from 'parse';
import ParseReact from 'parse-react';

Parse.initialize('MY_APPLICATION_ID');
Parse.serverURL = 'MY_PARSE_SERVER_URL';

var Advertisements = React.createClass({
  mixins: [ParseReact.Mixin], // Enable query subscriptions

  observe: function() {
    // Subscribe to all Advertisement objects, ordered by creation date
    // The results will be available at this.data.ads
    return {
      ads: (new Parse.Query('Advertisement')).ascending('createdAt')
    };
  },

  render: function() {
    // Render the text of each comment as a list item
    return (
      <ul>
        {this.data.ads.map(function(c) {
          return <li>{c.text}</li>;
        })}
      </ul>
    );
  }
});

class App extends React.Component {
    render() {
      return <div >< Advertisements /></div>
    }
}

export default App;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions