javascriptparse-serverparse-javascript-sdk

Parse fetches objects without any actual data


My Parse SDK seems to be doing weird things, check this out:

await Parse.User.logIn("testuser", "123asd");

this.initMap().then( correct => this.correctInit = correct);
    const places = await PlaceDAO.getAllForPosition(this.coords);
    this.placesList = places;
    console.log(this.placesList)

I login, and then I fetch all the places from this DAO method:

export class PlaceDAO {

    static async getAllForPosition(geopoint) {

        try {
            let query = new Parse.Query("Place");
            query.withinKilometers("location", {latitude: geopoint.lat, longitude: geopoint.lng}, 20);
            return await query.find();
        } catch (err) {
            console.log("DAO ERROR: ", err)
        }
    }


}

When I read what I receive, both after the query.find() or in the controller, what I see is these two objects; they have the proper ID, but none of the properties defined in the Parse class. ACL is configured for all public read-write in this class... Check it out:

enter image description here

Strangely, if I check the "network"...:

enter image description here

Yeah, it seems that my app actually receives the whole objects! Though this list is not accessible from the Parse SDK... it just cuts it down... why?


Solution

  • To access properties of a Parse.Object you need to use the .get(key) method. (see: https://docs.parseplatform.org/js/guide/#objects)

    For example:

    const places = await ParseDAO.getAllForPosition(position)
    places.forEach((place) => {
        console.log(place.get('placeName'))
    });
    

    This should log all the place names