Sample Javascript Code for Calling Cloud Code on Localhost
- [x] You've met the prerequisites: https://github.com/ParsePlatform/parse-server/wiki/Parse-Server-Guide#prerequisites.
- [x] You're running the latest version of Parse Server: https://github.com/ParsePlatform/parse-server/releases
- [x] You've searched through existing issues: https://github.com/ParsePlatform/Parse-Server/issues?utf8=%E2%9C%93&q=is%3Aissue Chances are that your issue has been reported or resolved before.
- [x] You have filled out every section below. Issues without sufficient information are more likely to be closed.
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
- 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]
Hi @ srmurrayray, check out the answers to your question on stackoverflow.
No solutions there.....
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.
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