Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sample Javascript Code for Calling Cloud Code on Localhost #2771

Closed
4 tasks done
srmurrayray opened this issue Sep 24, 2016 · 4 comments
Closed
4 tasks done

Sample Javascript Code for Calling Cloud Code on Localhost #2771

srmurrayray opened this issue Sep 24, 2016 · 4 comments

Comments

@srmurrayray
Copy link

srmurrayray commented Sep 24, 2016

Issue Description

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 = './cloud/main.js';
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

The Parse-Server-Example/test code calls my Cloud Code just fine. But, I can't follow the sample code in that example. I gather from various sources that the above code is how to properly call Parse-Server Cloud Code. Would be great to have a simple proper javascript method for calling Parse-Server Cloud Code.

I asked same question on Stackoverflow, but not getting very far there:

[http://stackoverflow.com/questions/39665496/calling-locally-hosted-parse-server-cloud-code-with-javascript(url)

Describe your issue in as much detail as possible.

see above

Steps to reproduce

Expected Results

call Cloud Code

Actual Outcome

see above

Environment Setup

  • Server
    • parse-server version <script type="text/javascript" src="http://www.parsecdn.com/js/parse-latest.js"></script>
    • Operating System: Linux
    • Hardware: Raspberry Pi3
    • Localhost or remote server? Localhost
  • Database
    • MongoDB version: 3.0.9
    • Storage engine:
    • Hardware: Raspberry Pi 3
    • Localhost or remote server? Localhost

Logs/Trace

You can turn on additional logging by configuring VERBOSE=1 in your environment.

[FILL THIS OUT]

@srmurrayray srmurrayray changed the title javascript code for calling cloud code localhost Sample Javascript Code for Calling Cloud Code on Localhost Sep 24, 2016
@acinader
Copy link
Contributor

acinader commented Sep 24, 2016

Hi @ srmurrayray, check out the answers to your question on stackoverflow.

@srmurrayray
Copy link
Author

No solutions there.....

@srmurrayray
Copy link
Author

I removed the "Parse.cloud = './cloud/main.js';" line. Still getting the same 404 error. Did not see any new answers on Stackoverflow. I've scoured the web for answers of how to use Javascript to call Parse-Server Cloud Code. Nothing other than the Parse-Server-Example/test which uses XHR, which I don't understand.

@acinader
Copy link
Contributor

Alrighty, I'm pretty sure I can help you out. I've got some questions: http://stackoverflow.com/questions/39665496/calling-locally-hosted-parse-server-cloud-code-with-javascript/39678505#39678505

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants