2017-12-02 26 views
0

내 Parse Server를 호출합니다. & Parse Javascript API를 사용하여 Angular V1 (JS 또는 IO?) 응용 프로그램에 데이터를 가져옵니다. 다음과 같이 내 통화 기능은 다음과 같습니다 이중 중첩 JSON 응답 파스 JavaScript API 가져 오기

$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 JSON 서버 응답 :

{ 
    "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" 
     }, 
     } 
    }, { 

모든 내가 retailerImage: r.get.Logo("url")를 사용하여 수집하려고 로고 URL을 제외하고, 성공적이다. 이 이중 중첩 항목은 어떻게 얻을 수 있습니까?

감사

+0

r.get : 당신은 그냥 r.get('Logo').url()

를 사용할 필요가 같이 여기 parse docs example의 보이는 ACL.Logo ('URL') –

답변

2

Logo 오른쪽 retailer의 또 다른 속성입니다?

var profilePhoto = profile.get("photoFile"); 
$("profileImg")[0].src = profilePhoto.url(); 
+1

그게 전부에요. 감사! –

+0

도와 드리겠습니다! :디 –