Last active
January 28, 2018 20:30
-
-
Save rodrigobdz/14f254f7e206a659822f3df620777cd0 to your computer and use it in GitHub Desktop.
Run single Parse Server function in the browser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="http://fb.me/react-0.13.3.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/parse/1.10.0/parse.js"></script> | |
</head> | |
<style type="text/css"> | |
* { | |
font-family: "Lucida Console", Monaco, monospace; | |
} | |
p { | |
background: #e6e6e6; | |
padding: 30px; | |
margin: 1px; | |
} | |
.success { | |
background: #97d9bd; | |
} | |
.error { | |
background: #FB9394; | |
} | |
</style> | |
<script type="text/javascript"> | |
document.addEventListener("DOMContentLoaded", function() { | |
function setText(label,value) { | |
var elem = document.getElementById(label) | |
elem.innerHTML = '<b>' + label + ':</b> ' + value | |
} | |
const Config = { | |
parse: { | |
url: 'http://localhost:1337', | |
appId: 'YOUR_APP_ID', | |
javascriptKey: 'YOUR_JAVASCRIPT_KEY', | |
functionName: 'YOUR_PARSE_FUNCTION_NAME', | |
functionParams: {}, | |
} | |
} | |
setText('url', Config.parse.url) | |
setText('function', Config.parse.functionName) | |
setText('params', JSON.stringify(Config.parse.functionParams, null, 4)) | |
// Parse Server initialization | |
Parse.serverURL = Config.parse.url | |
Parse.initialize(Config.parse.appId, Config.parse.javascriptKey) | |
// Run Parse Server function | |
Parse.Cloud.run(Config.parse.functionName, Config.parse.functionParams).then((result) => { | |
document.getElementById('result').classList.add('success'); | |
setText('result', result) | |
}, (error) => { | |
document.getElementById('result').classList.add('error'); | |
setText('result', error) | |
}) | |
}); | |
</script> | |
<body> | |
<p id="url"></p> | |
<p id="function"></p> | |
<p id="params"></p> | |
<p id="result"></p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Parse function runner
Run single Parse Server function in the browser
Requirements
Config
in parse_function_runner.html.Usage
parse_function_runner.html
.