I have a self hosted parse-server. However I can't seem to do a simple object save in javascript.
My server runs fine and am able to do the parse-server-example.
However, when I try to add a new page it doesn't appear to work.
In my Index.js I have the line
app.get('/testsave', function(req, res) {
res.sendFile(path.join(__dirname, '/public/simplesave.html'));
});
then in /public/simplesave.html:
<script src="/public/assets/js/simplesave.js"></script>
and finally in /public/assets/js/simplesave.js:
$(function() {
var TestObject = Parse.Object.extend("TestObject");
var testObject = new TestObject();
testObject.save({foo: "bar"}).then(function(object) {
alert("yay! it worked");
});
});
Replace this with a xhttp.send() however works. I think I am correct in assuming that Parse does not need to be initialised again and I can simple call Parse.
going to localhost:1337/testsave I would expect the function to be called and a TestObject. However I must be missing something.
答案 0 :(得分:0)
将此行添加到simplesave.html可行:
<script src="https://unpkg.com/parse/dist/parse.min.js"></script>