[英]Node.js with Parse Server GET
I am playing around with Parse Server and Node.js at the Moment and I am not very good in it. 我当时正在玩Parse Server和Node.js,但我做得不太好。 So i tried to make a call to my Parse Server from the Client.
因此,我尝试从客户端拨打我的Parse Server的电话。
Client Code: 客户代码:
$(document).ready(function () {
$.ajax({
type: 'GET',
url: '/usernames',
success: function (result) {
console.log(result);
}
})
})
Code in my main.js : 我main.js中的代码:
app.get('/usernames', function (req, res) {
var Userquery = new Parse.Query('Gamescore');
var namearray;
Userquery.find().then(function (results) {
for (name in results) {
namearray[name] = results[name].get('playerName');
}
res.success(namearray);
})
})
So after I execute the Code nothing happen and i dont know why exactly. 因此,在我执行代码后,什么也没有发生,我也不知道为什么。
Thank you for your help :) 谢谢您的帮助 :)
res.success belongs to ParseServer, useable in Parse Cloud like res.success属于ParseServer,可在Parse Cloud中使用,例如
Parse.Cloud.define('getUser',function (req, res) {
let query = new Parse.Query('..');
...
res.success(result); // or res.error(error)
})
where as your code is belongs to express route 您的代码在哪里属于快递路线
app.get('/usernames', function (req, res) {
let query = new Parse.Query('..');
...
res.json(result);
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.