How to access Backbone Fetch data server side How to access Backbone Fetch data server side flask flask

How to access Backbone Fetch data server side


@app.route('/my_url_here/<entityId>', methods=['GET', 'POST'])

isn't picking up any id because you aren't sending any.

Backbone fetch uses the id field of the model to construct the fetch URL, in your case I would recommend turning the entityId into id:

BB.Politician = Backbone.Model.extend({    defaults: {        type: "Politician"    },    url: "/my_url_here"});var currentUser = new BB.Politician({"id": "1625"});

and let Backbone construct the GET, which would look like:

"/my_url_here/" + this.get('id'); // this refers to model

which turns into

"/my_url_here/1625"

Backbone.Model.url also accepts function as value so you can define your own logic for constructing URLs. For instance, if you must retain the entityId you can construct your url like:

url: function () {    return "/my_url_here" + this.get('entityId');}