Search code examples
javascriptparse-platformparse-server

How to set up web app to talk to Parse Server (JavaScript)


I have Parse Server running on AWS and I wonder how to save an object to it. I'm not sure how to connect to Parse Server in my javascript file...

Do I do something like:

var Parse = require('parse');

Parse.initialize("YOUR_APP_ID");

Parse.serverURL = 'http://mypath'

Also, how do I include the Parse SDK in my js file?


Solution

  • It worked!

    <!doctype html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Untitled Document</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script type="text/javascript" src="https://npmcdn.com/parse/dist/parse.min.js"></script>
    <script>
        Parse.initialize("518e0dbca14e73748f81e550e12deea515ff959e");
        Parse.serverURL = 'http://ec2-35-165-199-91.us-west-2.compute.amazonaws.com:80/parse';
        var GameScore = Parse.Object.extend("GameScore");
        var gameScore = new GameScore();
        gameScore.save({playerName: "Kir"}).then(function(object) {
            alert("yay! it worked");
        });
    </script>
    </head>
    <body>
    </body>
    </html>