我有一个REST服务器,它在GET语句的请求主体中接受一个查询字符串。
它与Parse REST api类似。如下面的卷曲声明所示。
curl -X GET \
-H "X-Parse-Application-Id: ${APPLICATION_ID}" \
-H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
-G \
--data-urlencode 'where={"playerName":"Sean Plott","cheatMode":false}' \
https://api.parse.com/1/classes/GameScore
我的问题是:如何使用数据字符串发送Backbone fetch(本质上是-X GET)。
我尝试了以下内容;
fetch: function(options) {
options = _.extend({data: 'Active is true' }, options);
return Backbone.Collection.prototype.fetch.apply(this, arguments);
}
目前,将URL上的字符串作为参数附加
http://restserver.com/collection/Customer?Active%20eq%20true
答案 0 :(得分:0)
在集合类中,将url
属性实现为返回URL路径和所需查询字符串的函数。查询字符串可以从存储在集合实例上的属性(如collection.playerName
等)构建。此模式适用于搜索查询字符串类型用例,例如您的。