Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 如何将Parse.com与Node/Express和主干一起使用_Node.js_Backbone.js_Express_Parse Platform - Fatal编程技术网

Node.js 如何将Parse.com与Node/Express和主干一起使用

Node.js 如何将Parse.com与Node/Express和主干一起使用,node.js,backbone.js,express,parse-platform,Node.js,Backbone.js,Express,Parse Platform,我的待办事项清单已经准备好了。如果我按“添加”按钮添加一个新的todo,我可以坚持使用主干解析.com。唯一的问题是,如果我刷新页面,我刚才添加的所有待办事项都会消失。这是正确的,因为我现在实际上没有使用后端 在与Node/express集成时,我如何向parse.com发出post请求并获取当前的TODO 我在一篇教程中读到这样的内容: var Todos = Backbone.Collection.extend({ url: 'http://localhost:3000/api/todo

我的待办事项清单已经准备好了。如果我按“添加”按钮添加一个新的todo,我可以坚持使用主干解析.com。唯一的问题是,如果我刷新页面,我刚才添加的所有待办事项都会消失。这是正确的,因为我现在实际上没有使用后端

在与Node/express集成时,我如何向parse.com发出post请求并获取当前的TODO

我在一篇教程中读到这样的内容:

var Todos = Backbone.Collection.extend({
  url: 'http://localhost:3000/api/todos'
});
var TodosView = Backbone.View.extend({
  model: todos,
  el: $('.todos-list'), 
  initialize: function() {
    this.model.on('add', this.render, this);
    this.model.on('remove', this.render, this);
//this thing-----------
    this.model.fetch({
      success: function(response){
        _.each(response.toJSON(), function(item) {
          console.log('Successfully GOT todo with _id: '+ item._id);
        });
      },
      error: function() {
        console.log('Failed to get blogs!');
      }
    })
  },
//this thing end-----------
  render: function() {
    var self = this;
    this.$el.html('');
    _.each(this.model.toArray(), function(todo) {
      self.$el.append((new TodoView({model: todo})).render().$el);
    });
    return this;
  }
});
像这样的:

var Todos = Backbone.Collection.extend({
  url: 'http://localhost:3000/api/todos'
});
var TodosView = Backbone.View.extend({
  model: todos,
  el: $('.todos-list'), 
  initialize: function() {
    this.model.on('add', this.render, this);
    this.model.on('remove', this.render, this);
//this thing-----------
    this.model.fetch({
      success: function(response){
        _.each(response.toJSON(), function(item) {
          console.log('Successfully GOT todo with _id: '+ item._id);
        });
      },
      error: function() {
        console.log('Failed to get blogs!');
      }
    })
  },
//this thing end-----------
  render: function() {
    var self = this;
    this.$el.html('');
    _.each(this.model.toArray(), function(todo) {
      self.$el.append((new TodoView({model: todo})).render().$el);
    });
    return this;
  }
});
this.model.fetch正在尝试从上面的url获取,但该教程使用的是MongoDB。我如何使用parse.com做同样的事情

如果你能解释你的答案,那就太棒了,因为我昨天刚刚试着学习主干/节点/表达式/解析

var Messages = Backbone.Collection.extend({
  model:Message,
  url:'https://api.parse.com/1/something/something',
  getMessages:function() {
    this.fetch({
      data:{
        order:'-createdAt' 
      }
    });
  },

  parse:function(response, options) {
    return response.results.reverse();
  }

});
在您的示例中,您正在获取并发布到自己的计算机
http://localhost:3000/api/todos
我猜您从教程中学到了这一点。在parse.com上设置和帐户,并签出码头。您将更改url以匹配其API。查看他们的RESTAPI文档了解详细信息

在您的示例中,您正在获取并发布到自己的计算机
http://localhost:3000/api/todos
我猜您从教程中学到了这一点。在parse.com上设置和帐户,并签出码头。您将更改url以匹配其API。查看他们的RESTAPI文档了解详细信息