下面是我的AirTableService.js
(function () {
"use strict";
var AirTableService = function ($http, $q) {
var AirTableMethods = {
getMyRounds: function(AirTable_secret){
var deferObject_myRounds;
var myRounds_promise = $http.get('https://api.airtable.com/v0/XXXXXXX/Rounds?view=Main%20View&maxRecords=10&callback=JSON_CALLBACK', {
headers : {
'Authorization' : AirTable_secret.apikey,
'Content-Type' : 'application/json'
}
});
deferObject_myRounds = deferObject_myRounds || $q.defer();
myRounds_promise.then(function(data){
deferObject_myRounds.resolve(data);
});
return deferObject_myRounds.promise;
}
};
return AirTableMethods;
};
AirTableService.$inject = ['$http', '$q'];
angular.module('appGolf')
.service('AirTableService', AirTableService);
}());
如您所见,使用AirTable我api
正在尝试GET
从我的表中获取数据。我正在传递参数view
并且maxRecords
它有效。文件说明我可以通过sort
,
然后我改为,
https://api.airtable.com/v0/XXXXXXX/Rounds?view=Main%20View&maxRecords=10&sort=[{field:'RoundID',direction:'desc'}]&callback=JSON_CALLBACK
很明显,这不起作用,它给了我这个错误,
我知道这是因为是 a并且我知道我如何传递这是不正确的。sort
array of objects
我的问题是,你如何做到这一点AngularJS
?
先感谢您。