0
votes

I have Parse-Server hosted locally and I have the Parse-Server-Example test working. I'm able to call the example cloud code function using the test code (/test) that Parse-Server-Example uses. When I replace the main.js file with my legacy cloud code (from Parse.com hosted server), I can't seem to figure out how to call it. The Parse-Server-Example /test call to my replaced cloud code works just fine. I just can't seem to call the cloud code from my own javascript. Here's my client side javascript code:

function helloMyParse(){
Parse.initialize("myAppId", "myMastKey");
Parse.serverURL = 'http://192.168.1.239:1337/parse';
Parse.Cloud.run('hello', 
    { 
    XXXXXXX
    }, {
        success: function(results) {

Any ideas greatly appreciated!

Above code throws the following error:

  Failed to load resource: the server responded with a status of 404 (Not Found)   http://192.168.1.239:1337/parse/1/functions/hello
3
u could try grep on *js for that "/1" in the path. Dont think u should have the /1 any longer... but i cant tell where the request for that path is coming from. - Robert Rowntree
Yeah. Odd. the "/1/functions/" in the path is being generated by Parse-Server. It's definitely not in my code. - hypermiler
may be worth looking at the CC-router in a debugger... parse-server/routers/cloudcoderouter.js - Robert Rowntree

3 Answers

0
votes

Try removing the line Parse.cloud = ...

Also, this is Parse.Cloud.run with a capital C

0
votes

The problem is the /1 in your url. You also shouldn't need:

Parse.cloud = './cloud/main.js'; though it probably isn't causing any harm.

How are you running the above code? Is it in its own file? Where?

Let's see if we can start here. Open a command line and try this:

curl -X POST \
  -H "X-Parse-Application-Id: ### your're app id here ####" \
  -H "Content-Type: application/json" \
  -d '{"foo":"bar"}' \
  http://192.168.1.239:1337/parse/functions/hello
0
votes

My bad. I was using an old version of Parse SDK. The parsecdn is not the latest. Cloud code requires the latest SDK. The new SDK knows where Cloud Code lives. Problem solved

    <!--  Replaced 09-23-16     <script type="text/javascript" src="http://www.parsecdn.com/js/parse-latest.js"></script> -->

    <!--  New CDN  09-24-16-->    
    <script type="text/javascript" src="https://npmcdn.com/[email protected]/dist/parse.min.js"></script>