Skip to content

Instantly share code, notes, and snippets.

@rodrigobdz
Last active January 28, 2018 20:30
Show Gist options
  • Save rodrigobdz/14f254f7e206a659822f3df620777cd0 to your computer and use it in GitHub Desktop.
Save rodrigobdz/14f254f7e206a659822f3df620777cd0 to your computer and use it in GitHub Desktop.
Run single Parse Server function in the browser
<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>
@rodrigobdz
Copy link
Author

rodrigobdz commented Sep 5, 2017

Parse function runner

Run single Parse Server function in the browser

Requirements

  • Set the variable Config in parse_function_runner.html.

Usage

  1. Download parse_function_runner.html.
  2. Open it in a browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment