我不知道我必须做些什么才能让它在这里工作是代码:
Songs = new Mongo.Collections("songs");
if (Meteor.isClient) {
// counter starts at 0
Session.setDefault('counter', 0);
Template.hello.helpers({
counter: function () {
return Session.get('counter');
}
});
Template.hello.events({
'click button': function () {
// increment the counter when button is clicked
Session.set('counter', Session.get('counter') + 1);
}
});
}
if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
});
}
这是错误: TypeError:undefined不是函数 在newapp.js:1:9
我所做的只是添加1行。另外,我如何在浏览器Javascript控制台中运行相应的Javascript代码,以将项目插入到Songs集合中。 我是初学者。
答案 0 :(得分:1)
使用JSONObject paramsVolley = new JSONObject();
try {
paramsVolley.put("u_id", 4);
} catch (JSONException e1) {
e1.printStackTrace();
}
JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.POST, "http://admin:1234@greentin.com/apiuser/getuserdet/format/json", paramsVolley, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Toast.makeText(getApplication(), response.toString(), Toast.LENGTH_SHORT).show();
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> headers = new HashMap<>();
String credentials = "admin:1234";
String auth = "Digest " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP);
headers.put("Content-Type", "application/json");
headers.put("Authorization", auth);
return headers;
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError e) {
Toast.makeText(getApplicationContext(), "Error Occurred",Toast.LENGTH_SHORT).show();
}
});
GoGreen.getInstance().addToRequestQueue(jsonObjReq, tag_update_det);
代替Mongo.Collection
。最后Mongo.Collections
没有必要。