0

I am calling my Parse Server & pulling data down using the Parse Javascript API into my Angular V1 (is that JS or IO?!) application. My call function is as follows:

$scope.getInventoryItems = function () {

    var query = new Parse.Query("Inventory");
    query.include("product");
    query.include("retailer");
    query.find({

        success: function (results) {

            $scope.inventoryItems = [];

            for (i = 0; i < results.length; i++) {

                var p = results[i].get("product");
                var r = results[i].get("retailer");

                var inventoryItem = {

                    objectId: results[i].id,
                    productObjectId: p.id,
                    barcode: p.get("barcode"),
                    productName: p.get("name"),
                    imageUrl: p.get("image"),
                    Qty: results[i].get("QTY"),
                    newQty: results[i].get("QTY"),
                    shoppingQty: 1,
                    retailerImage: r.get.Logo("url"),
                    retailerName: r.get("Name")
                }
                console.log(inventoryItem);
                $scope.inventoryItems[$scope.inventoryItems.length] = inventoryItem;

            }

            $scope.$apply();

        },
        error: function (error) {
            console.log("Query Error: " + error.message);
        }
    })
}

Heres the JSON server response:

{
    "results": [{
        "objectId": "Fo02snRmlP",
        "product": {
            "objectId": "eCA7BwB7kF",
            "barcode": 54775912,
            "name": "Extra Peppermint Gum 5 Pack",
            "image": "[image url removed]",
            "createdAt": "2017-11-22T01:28:16.605Z",
            "updatedAt": "2017-11-22T01:28:16.605Z",
            "__type": "Object",
            "className": "Products"
        },
        "QTY": 4,
        "createdAt": "2017-11-22T01:28:16.859Z",
        "updatedAt": "2017-11-22T01:28:16.859Z",
        "ACL": {
            "NV6ubzeAHL": {
                "read": true,
                "write": true
            }
"retailer": {
            "objectId": "u2qNoKDAWV",
            "Name": "My Supermarket",
            "createdAt": "2017-09-20T17:16:48.151Z",
            "updatedAt": "2017-11-13T19:40:26.371Z",
            "Logo": {
                "__type": "File",
                "name": "c600325c63f7fb252b36c08c8c6168ab_supermarket_logo_full.svg",
                "url": "https://my-api.herokuapp.com//files/my-api/c600325c63f7fb252b36c08c8c6168ab_supermarket_logo_full.svg"
            },
            "shortName": "supermarket",
            "__type": "Object",
            "className": "Retailers"
        },
        }
    }, {

Everything is successful, except for the logo URL which I am trying to collect using retailerImage: r.get.Logo("url"). How would I get this double nested item?

Thanks

1
  • r.get:ACL.Logo('url') Commented Dec 2, 2017 at 21:07

1 Answer 1

2

Logo is another property of retailer, right? Looks like you just need to use r.get('Logo').url()

Here's the parse docs example:

var profilePhoto = profile.get("photoFile");
$("profileImg")[0].src = profilePhoto.url();
Sign up to request clarification or add additional context in comments.

2 Comments

Thats it. Thanks!
Happy to assist! :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.