parse-community / ParseReact

Seamlessly bring Parse data into your React applications.
https://parseplatform.org
Other
1.3k stars 209 forks source link

XMLHttpRequest cannot load https://api.parse.com/1/undefined #109

Closed taylorstine closed 9 years ago

taylorstine commented 9 years ago

Any time I call ParseReact.Mutation.Set I get the error XMLHttpRequest cannot load https://api.parse.com/1/undefined
Here is what my code looks like:

var Entry = React.createClass({
  mixins: [ParseReact.Mixin],
  observe: function (props) {
    return {
      score: (new Parse.Query('Score')).containedIn('objectId', _.pluck(props.score, 'objectId'))
    }
  },
  render: function () {
    var scoreNodes = [];
    var title = null;
    if (this.pendingQueries().length == 0) {
      scoreNodes = _.map(this.data.score, function (score) {
        return (
          <Score
            key={score.objectId}
            units={score.units}
            value={score.value}
            update={this._updateScore.bind(this, score.id)}
          />
        )

      }, this);
      title = <EntryTitle name={this.props.name}
                  onTitleChange={this.handleTitleChange}/>
    }

    return (
      <div>
        {title}
        <button onClick={this.deleteEntry}>Delete</button>
        <div ref="scores">
          {scoreNodes}
        </div>
        <button onClick={this.addScore}>Add Score</button>
      </div>
    )
  },
  _updateScore: function(scoreId, score) {
    ParseReact.Mutation.Set(scoreId, {
      value: 1000
    }).dispatch();

  },

});
andrewimm commented 9 years ago

Can you provide more information on which versions of the parse and parse-react npm modules you are using?

taylorstine commented 9 years ago

my package.json includes the following (obtained by running npm install --save parse parse-react):

    "parse": "^1.6.1",
    "parse-react": "^0.4.3",
andrewimm commented 9 years ago

parse-react is currently tied to using version 1.5.0 of the Parse SDK until it can be updated. We should have 0.5.0 out later today which will update it to the new SDK, but in the meantime, you should downgrade your version of parse.

taylorstine commented 9 years ago

:+1: worked like a charm

mbifulco commented 9 years ago

@taylorstine I'm having the same issue... I've currently got my versions set as follows:

  "dependencies": {
    "react": "^0.13.0",
    "parse": "1.5.0",
    "parse-react": "^0.1.3"
  }

I'm also getting a CORS error alongside the 404, which I assume is related:

XMLHttpRequest cannot load https://api.parse.com/1/undefined. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8888' is therefore not allowed access. The response had HTTP status code 404.

For context, I'm running the code found here without any modification aside from the addition of my Parse app and Javascript Keys.

What am I missing? I can confirm that Parse 1.5.0 is loaded - I did an npm install to back it down to that version after seeing this bug.

taylorstine commented 9 years ago

@mbifulco can you confirm what version of parse-react you are using? It should match the one I have based on your dependency, but just to confirm.

mbifulco commented 9 years ago

0.1.4

taylorstine commented 9 years ago

try explicitly upgrading to 0.4.3

mbifulco commented 9 years ago

That did the trick! Thanks @taylorstine.

@andrewimm... it might help others to leave this issue opened until it is truly fixed. I had to do some digging to find it!

andrewimm commented 9 years ago

Actively working on getting this to play nicely with 1.6.0 (#110). I'm currently just trying to split out a separate react native build, then 0.5.0 will be ready for release.

treeder commented 8 years ago

I'm getting this error using https://www.parsecdn.com/js/parse-react.js , but I see that URL is v0.4.2, how do I get the latest parse-react?

mbifulco commented 8 years ago

@treeder more recent versions are available on npm - that's where I've been pulling mine from. https://www.npmjs.com/package/parse-react

treeder commented 8 years ago

Using npm and everything is the latest (ie: nothing shows up when I do npm outdated).

XMLHttpRequest cannot load https://api.parse.com/1/undefined. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 404.