I have a working curl call:
curl -X GET \
-H "X-Parse-Application-Id: XXXX" \
-H "X-Parse-REST-API-Key: YYYY" \
-G \
--data 'where={"number":1}' \
https://api.parse.com/1/classes/Day
How do I translate this into an angular $http call? I have tried every permutation I can think of, and it still retrieves every Day object. Base on the documentation, I expected the following to work:
$http({method: 'GET', url: 'https://api.parse.com/1/classes/Day',
data: {"where": {"number": 1}}});
EDIT: I updated my code to use the Parse JavaScript SDK as recommended in the accepted solution. I installed it using bower:
bower install --save parse
In my app.js I initialize Parse:
Parse.initialize(parseAppId, parseJavascriptKey);
The controller code is a lot more verbose than what I had before, but does work correctly and provides more flexible querying:
var Day = Parse.Object.extend("Day");
var query = new Parse.Query(Day);
query.equalTo("number", currentDay); // Only retrieve objects matching currentDay
query.include('challenge,quote'); // Related objects
query.find({
success: function(results) {
console.log("Retrieved object with id: " + results[0].get('id'));
$scope.day = results[0];
$scope.$apply();
},
error: function(error) {
console.log(err);
}
});