alexbhandari
alexbhandari

Reputation: 1398

Using parse in a javascript interpreter environment

It would be very helpful for me to test my parse.com javascript code in an interpreter environment. So I can query an object and see the response immediately.

Node.js comes with an interpreter, but I need to figure out how to import the parse object. This seems to be done through the parse.js file (http://www.parsecdn.com/js/parse-1.2.19.min.js). In the parse tutorials it is included in <script> tags in the html like so

<script type="text/javascript" src="http://www.parsecdn.com/js/parse-1.2.19.min.js"></script>

But for this I need to figure out how to do the import using javascript. Does anyone know how to import an external file? I tried require("http://www.parsecdn.com/js/parse-1.2.19.min.js") but got an error.

Update:

I was able to import the Parse code by downloading the parse file and using require locally with
var Parse = require("./parse-1.2.19.min.js");

Localstorage and xmlhttprequest have to be installed beforehand for this to work. However when I do Parse.initialize(-removed keys-) I get

TypeError: Object function (e){return e instanceof w?e:this instanceof w?(this._wrapped=e,void 0):new w(e)} has no method 'initialize'

Upvotes: 0

Views: 324

Answers (1)

Paul
Paul

Reputation: 36339

So you won't use the CDN file, since that's written for the browser and the environment is different.

From the parse.com blog, you can get the SDK for nodejs through npm and then require it like you normally would in node.

npm install parse

var parse = require('parse').Parse;

Full article here: http://blog.parse.com/2012/10/11/the-javascript-sdk-in-node-js/

Upvotes: 1

Related Questions