0

Hey all I've been using Parse.com as a back end for an angularjs web app I'm working on and recently I've run into some problems with GeoPoint queries. I'm trying to get a list of the 10 closest venues in the database with the following $http query.

$http({method:'GET',
     url: 'https://api.parse.com/1/classes/Venue',
     params: { limit:10, where:{"GeoLocation":{"$nearSphere":  {"__type":"GeoPoint","latitude":40.730669, "longitude":-74.063631}}}},
     isArray:true,
     headers: {'X-Parse-Application-Id':'XXXXXXXX',
               'X-Parse-REST-API-Key':'YYYYYYYYY',
              }
     });

everytime I get error code: 1 internal error response from parse. I've gotten in touch with parse.com about this one as recommended but they've not been the speediest in responding. I was wondering if anyone else has run into this problem and had found a solution. Thanks in advance

Alexander Romero
  • 401
  • 5
  • 10

1 Answers1

2

If you JSON stringify Geolocation then it should work

var geocodeObj, paramsObj;

geocodeObj = {
  "Geolocation": {
    "$nearSphere": {
      "__type": "GeoPoint",
      "latitude": 40.730669,
      "longitude": -74.063631
    }
  }
};

paramsObj = {
  "limit": 10,
  "where": JSON.stringify(geocodeObj)
};

$http({
  "method": "GET",
  "url": "https://api.parse.com/1/classes/Venue",
  "params": paramsObj,
  "isArray": true,
  "headers": {
    "X-Parse-Application-Id": "xxx",
    "X-Parse-REST-API-Key": "xxx",
    "Content-Type": "application/json"
  }
}).success(function(data, status, headers, config) {
}).error(function(data, status, headers, config) {
});
carrie
  • 31
  • 5